How to create a service in web interface without creating a collection named not "xxx_xxx" but "xxx"?

59 Views Asked by At

each time to create service in web interface,a collection named like "xxx_xxx" will be created,question is

 How to create collection named not "xxx_xxx" but "xxx"?
1

There are 1 best solutions below

3
On

Foxx will automatically prefix the name based on the mount path of the service. That's intentionally to avoid conflicts with other services.

You could use a non-prefix "xxx" collection as well if you use the low-level db._collection method to access this collection.

In the corresponding documentation you find suggestions on how to share collections between services as well: https://docs.arangodb.com/3.11/develop/foxx-microservices/guides/working-with-collections/

Example Route /some_products:

router.get('/some_products', function (req, res) {
  res.set("Content-Type", "text/plain; charset=utf-8");

  const { db, aql } = require("@arangodb");
  const query = aql`
    FOR doc IN products
      LIMIT 10
    RETURN doc
  `;
  res.json(db._query(query).toArray());
}