3 ms·
hmm, I wonder how hard it would be to make a JavaScript driver that lets you manipulate data just like you do in JavaScript, eg. using map,reduce/filter, push e
by z3t4 8y ago
hmm, I wonder how hard it would be to make a JavaScript driver that lets you manipulate data just like you do in JavaScript, eg. using map,reduce/filter, push etc. For me it's a lot of overhead when switching back and forth between different languages, eg. between JS and SQL. Even though SQL is a powerful language and I'm really good at it.
- rajangdavis 8y agoMaybe this? https://github.com/plv8/plv8 https://github.com/plv8/plv8
- miedpo 8y agoArrange has this kinda, with caveats. It's called Foxx.
- pluma 8y ago(full disclosure: I work for ArangoDB but this is my own personal opinion) Coming from a JS background AQL is actually pretty easy to learn. Personally the only thing that keeps tripping me up is that AQL doesn't have a triple-equals and JS has trained me to avoid double-equals in comparisons. This is how you fetch every user in a collection: FOR user IN users RETURN user This is how you fetch every admin: FOR user IN users FILTER user.role == "admin" RETURN user This is how you fetch their email addresses: FOR user IN users FILTER user.role == "admin" RETURN user.email Compare this to the equivalent in SQL: SELECT email FROM users WHERE role == "admin" The AQL example is IMO easy to read if you know JS or any similar language. AQL even has object and array literals. There are a few idiosyncrasies but you can get very far without needing to invest time to "properly" learn the language. The naive approach usually results in pretty good performance out of the box. I'd say the mental overhead of switching into AQL and out doesn't quite compare to that of e.g. SQL or even MongoDB queries but you are of course correct that there is some overhead nevertheless. That said, there are community-maintained ODMs for ArangoDB if you don't want to touch another language to write the queries by hand. I would strongly recommend giving AQL a try though. When I started using ArangoDB (before becoming a contributor) I was hesitant as well but what quickly won me over was that I was able to read most AQL queries without having to learn an entirely new language.
- z3t4 8y ago> This is how you fetch every user in a collection: await db.users This is how you fetch every admin: await db.users.filter( user => user.role == "admin" ) This is how you fetch their email addresses: await db.users.filter( user => user.role == "admin ).map( user => user.email ) I think it can be done using JavaScript Proxy. Here's an update query: user.email = "updated@email.ltd"