arangodb / arangojs

The official ArangoDB JavaScript driver.
https://arangodb.github.io/arangojs
Apache License 2.0
600 stars 106 forks source link

How to debug aql-template queries? #768

Closed tonn closed 2 years ago

tonn commented 2 years ago

Usually I copy query to/from arangodb web interface for testing. It works with old-style binding. But for aql-templates I have to convert query and it becomes completely unusable. Maybe there is auto converter for aql-templates? Or other way to debug queries?

pluma4345 commented 2 years ago

If you want to use regular AQL syntax, you can pass a regular (raw) query string instead of an AQL template strings. Note that you will have to handle the bindVars object yourself and make sure to correctly indicated @collection parameters. The API documentation shows examples for both variants as overloaded methods.

Personally I copy the queries from my JS/TS code as-is and replace the ${arg} template syntax with hardcoded values during manual experimentation. This can get tedious when dealing with lots of bind parameters of course.

Note that this syntactical difference is imposed by JavaScript, not arangojs, so there's no way to make AQL template strings look like raw AQL query strings.