无法在Foxx中切换到_system以外的数据库 [英] Can't switch to database other than _system within Foxx

查看:92
本文介绍了无法在Foxx中切换到_system以外的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在应用程序启动时动态生成数据库/集合,以防它们尚不存在.使用_system数据库时,此方法工作正常.问题是,尝试切换到其他数据库时似乎不允许这样做.从文档中:

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.

在某些情况下,可能不允许更改数据库,因为 服务器端操作示例(包括Foxx).

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

这是否意味着Foxx应用程序只能在_system数据库中创建集合?我的清单文件将isSystem属性设置为false.这种限制是什么意思?

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?

推荐答案

Foxx包含在一个数据库上下文中,并且可以访问那里的集合. 您可以在其他数据库中安装Foxx应用程序. f.E.您可以在arangosh中运行以下命令以将foxx应用"example"安装在数据库"myDB"中:

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

故意无法从Foxx应用程序中访问其他数据库.

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

这篇关于无法在Foxx中切换到_system以外的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆