Reputation: 9942
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"?
Upvotes: 0
Views: 51
Reputation: 159
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());
}
Upvotes: 0