arangodb / arangojs

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

Collection and graph check: API request #753

Closed gitgkk closed 2 years ago

gitgkk commented 2 years ago

I'm using the pyarango and the JS drivers on my project but the APIs are not the same on the JS side. The https://pyarango.readthedocs.io/en/latest/database/ has

both of which are very handy and create a clean code rather than using the current

My request is that the dev team implement an efficient version which works has the same interface and work like the pyarango api version cited above.

Thanks!

meadowsys commented 2 years ago

i think for hasCollection you can do something like this:

let collection_exists = await db.collection("collection_name").exists();

not sure about hasGraph though

pluma commented 2 years ago

You can do the same for Graph: await db.graph("graph_name").exists()

pluma commented 2 years ago

I'm closing this as there is no significant advantage in having these aliased on the Database object simply because pyArango went this way. The advantage of using the exists() method is that you will need to perform any other operations via the Collection or Graph object anyway and there are very few scenarios where you only want to check for existence and do nothing else with that collection or graph (and in those, you can still do it as above).

Feel free to reopen if you think the API is insufficient.