Confused about collectionname's in Foxx.createQuery and default collectionnames

36 views
Skip to first unread message

Julian May

unread,
Dec 7, 2015, 6:53:39 AM12/7/15
to ArangoDB
Hey

I'm having some problems figuring out what to do:

1: For complex-queries I use AQL in a Foxx.createQuery(...) statement, extending the respective repository.
2: The names of the collections created by the setup-rutine of the foxx-app prepends the "mount"-name of the app to the collectionnames

So, how do i know what the collectionname is called? I have no problem using a @@collectionname bind-parameter to the query, i just need to know what the value for that bind-parameter is.

Thanks :)

/Julian

Alan Plum

unread,
Dec 7, 2015, 7:56:48 AM12/7/15
to ArangoDB
Hello Julian

you are right that collections for Foxx apps (or "services" as of 2.7) are typically prefixed with a string based on the app's mount path. This allows using arbitrary collection names without running into conflicts with other Foxx apps or other mounted copies of the same app.

You can use the applicationContext to get references to these collections by their unprefixed names. The applicationContext is available in Foxx apps and provides the two methods "collection" and "collectionName".

If you just want the prefixed name of a collection, you can pass the unprefixed name to applicationContext.collectionName and it will return the prefixed name as a string.

If you want a reference to the collection itself, you can pass the unprefixed name to applicationContext.collection and it will return the collection. This is equivalent to passing the prefixed name to db._collection from the org/arangodb module.

Additionally, if you already have a reference to a collection, you can access its full name from its "name" property. Or if you have a repository instance wrapping a collection you can access the repository's collection using it's "collection" property.

Hope this helps,

Alan from ArangoDB

Julian May

unread,
Dec 7, 2015, 10:24:48 AM12/7/15
to ArangoDB
Perfect, thank you :)

/Julian
Reply all
Reply to author
Forward
0 new messages