Closed solher closed 8 years ago
That's a good Idea! I will do it :) I will keep you updated. I have 2.6 update pending, so I will release both changes. And probably 2.7 ;) You are welcome!
Thanks a lot !
Hum... I've been working all day on the best way of filtering ArangoDB results and I think I'm going to follow another idea than the one I chose at the beginning.
ArangoDB, unlike SQL databases, allows a lot of data formatting inside AQL queries. To the point that when you query:
FOR d
IN documents
RETURN {
document: d,
metaData: (
FOR m
IN metaData
FILTER m.documentId == d._id
RETURN m
)
}
You don't really know what to put the filter on. I think I'm going to allow JSON filters like that (passed by query parameters from the API client):
{
"limit": 2,
"offset": 1,
"where": {
"and": [
{"document._id": "document/4134113213"},
{"metaData.title": { "neq": "foobar" } }
]
}
}
To AQL:
LET result = (
FOR d
IN documents
RETURN {
document: d,
metaData: (
FOR m
IN metaData
FILTER m.documentId == d._id
RETURN m
)
}
)
FOR var
IN result
LIMIT 1, 2
FILTER var.document._id == "document/4134113213" && var.metaData.title != "foobar"
RETURN var
It will not be the prettiest way all the time but I think it is the most powerful and versatile one for the client, and the easiest for the API developer.
I see your point. I will review my code I see If I can improve JSON2AQL, yours is a good idea. Anyway, I moved orm and aql into 2 sub packages. Branch: json2aql. regards!
I just released my driver on GitHub ! I reused the query generator I wrote for SQL, check it out: https://github.com/solher/arangolite Looks like you're not alone anymore using ArangoDB with Go haha.
Thanks a lot for your work anyway ;)
:D great! :)
Oh and just one thing. How do you feel about the ArangoDB transaction system ?
To me, the way they force you to write a Javascript function is just disgusting. You end up with JS code everywhere inside your Go code.
Yes. same here. I guess we should build some kind of wrapper. But we need to include javascript in Golang driver :( . One solution I found quite interesting, is to send JSON to the server, with actions to do in a transaction and data, then build corresponding Fox app to do it server side.
Hi, I'm currently writing my own lightweight ArangoDB driver. Just 50 lines to run raw AQL because I don't need all the ORM-like features. I love your JSON2AQL feature (as I wrote the same thing for SQL) and I'd like to use it in my package. Could you move the feature in a separate package (or more easily inside a subpackage) ? I will pull request to help you write tests if you want.
I will use it like that:
Thanks for your work !