Why in ArangoDB module.context.collection return null

て烟熏妆下的殇ゞ 提交于 2019-12-24 10:41:18

问题


I'm trying to learn how to develop Foxx services.

There are many examples where people use:

const someCollection = module.context.collection('someCollectionName');

But in my project this code doesn't work. someCollection always null, but it's exist in collections.

And this code works perfectly:

const db = require('@arangodb').db;
const someCollection = db._collection('someCollectionName');

My question is why first code isn't work?


回答1:


Foxx services are intended to have their own collections, and being able to be installeable multiple times.

Thus module.context.collection('someCollectionName'); will give you a collection prefixed with the mountpoint of your Foxx-Service, wheres db._collection('someCollectionName'); will always give you the same collection name regardles of which installation of this foxx services you are in - thus several installations may interfere each other.

The easiest way to get started with a complete example that has collections and simple code stubs for manipulation is to choose this clickpath in the UI:

Services -> Add Service=> New

And fill

'someCollectionName' into Document Collections:



来源:https://stackoverflow.com/questions/47976621/why-in-arangodb-module-context-collection-return-null

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!