Working with collections

    The prefixes may initially feel unnecessarily verbose but help avoid conflictsbetween different services with similar collection names or even multiplecopies of the same service sharing the same database. Keep in mind that youcan also use collection objects when writing queries,so you don’t need to worry about writing out prefixes by hand.

    As a rule of thumb you should always use module.context.collectionto access collections in your service.

    Using these methods requires you to work with fully qualified collection names.This means instead of using to get acollection object you need to use module.context.collectionNameto get the prefixed collection name ArangoDB understands:

    Sharing collections

    The most obvious way to share collections between multiple services is to usean unprefixed collection name and then use the low-level db._collectionmethod to access that collection from each service that needs access to it.

    The cleanest approach is to instead decide on a single service which managesthe collection and set up explicit dependencies betweenthe different services using the collection:

    1. const users = module.dependencies.usersService.users;

    This approach not only makes the dependency on an externally managed collectionexplicit but also allows having those services still use different collectionsif necessary by providing multiple copies of the service that provides theshared collection.