Can't switch to database other than _system within Foxx

三世轮回 提交于 2019-12-12 18:20:00

问题


I'm trying to dynamically generate databases/collections on application startup, in case they do not exist yet. This works fine when working with the _system database. The thing is that it seems not to be allowed when trying to switch to other databases. From the docs:

db._useDatabase(name)

Changes the current database to the database specified by name. Note that the database specified by name must already exist.

Changing the database might be disallowed in some contexts, for example server-side actions (including Foxx).

Does this mean that Foxx applications can only create collections within the _system database? My manifest file sets the isSystem property to false. What is the meaning of such limitation?


回答1:


A Foxx is included in one database context and has access to the collections there. You can install Foxx apps in different databases. f.E. you can run the following commands in arangosh to install the foxx app "example" in the database "myDB":

db._useDatabase("myDB")
fm.install("example","/example")

your app will than be reachable at (assuming standard configuration):

http://localhost:8529/_db/myDB/example

It is intentionally not possible to access a different database from within a Foxx app.



来源:https://stackoverflow.com/questions/24934374/cant-switch-to-database-other-than-system-within-foxx

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