[英]How to “Import Queries” in the Web Interface of ArangoDB?
"Export Queries" does not work in the Query tab of the Web Interface , so I tried to manually create json with the query and import it, but the following definition is not clear: “导出查询” 在Web Interface的 “查询” 选项卡中不起作用,因此我尝试使用查询手动创建json并将其导入,但是以下定义不清楚:
Format:
JSON documents embedded into a list:
[{
"name": "Query Name",
"value": "Query Definition",
"parameter": "Query Bind Parameter as Object"
}]
What escaping should have the value
, whether parameter
is mandatory and what is the format in case multiple bind parameters are defined. 什么转义应该具有
value
,无论parameter
是强制性的,还是在定义多个绑定参数的情况下是什么格式。
I was not able to import the following script: 我无法导入以下脚本:
[{
name: "Create Random Complex Users (num, outpUsers)",
value: '// Create specified number of users in the users Vertex collection
FOR i IN 1..@usersNum
INSERT {
id: 100000 + i,
age: 18 + FLOOR(RAND() * 50), // RAND generate float E {0, 1]
name: CONCAT('user', TO_STRING(i)),
} IN @@users'
}
]
What is wrong and how should it be fixed? 有什么问题,应该如何解决?
NOTE: ArangoDB version: arangosh (ArangoDB 3.0.10 [linux] 64bit, using VPack 0.1.30, ICU 54.1, V8 5.0.71.39, OpenSSL 1.0.1f 6 Jan 2014)
注意: ArangoDB版本:
arangosh (ArangoDB 3.0.10 [linux] 64bit, using VPack 0.1.30, ICU 54.1, V8 5.0.71.39, OpenSSL 1.0.1f 6 Jan 2014)
Using the JSON fixed by @mpv1989 the following error appears in the Web Inetface: Query error: queries could not be imported
. 使用@ mpv1989修复的JSON,Web Inetface中将出现以下错误:
Query error: queries could not be imported
。 And the following message is in the log using DB named test
under the root user: 在根用户下使用名为
test
数据库在日志中显示以下消息:
2016-10-26T12:31:28Z [31690] ERROR Service "/_admin/aardvark" encountered error 500 while handling POST http://localhost:8529/_db/test/_admin/aardvark/query/upload/root
2016-10-26T12:31:28Z [31690] ERROR ArangoError: users can only be used in _system database
2016-10-26T12:31:28Z [31690] ERROR at getStorage (/usr/share/arangodb3/js/server/modules/@arangodb/users.js:93:17)
2016-10-26T12:31:28Z [31690] ERROR at Object.exports.document (/usr/share/arangodb3/js/server/modules/@arangodb/users.js:291:17)
2016-10-26T12:31:28Z [31690] ERROR at Route._handler (/usr/share/arangodb3/js/apps/system/_admin/aardvark/APP/aardvark.js:153:18)
2016-10-26T12:31:28Z [31690] ERROR at next (/usr/share/arangodb3/js/server/modules/@arangodb/foxx/router/tree.js:386:15)
2016-10-26T12:31:28Z [31690] ERROR at /usr/share/arangodb3/js/node/node_modules/lodash/lodash.js:9378:25
2016-10-26T12:31:28Z [31690] ERROR at Middleware.authRouter.use (/usr/share/arangodb3/js/apps/system/_admin/aardvark/APP/aardvark.js:78:3)
2016-10-26T12:31:28Z [31690] ERROR at next (/usr/share/arangodb3/js/server/modules/@arangodb/foxx/router/tree.js:388:15)
2016-10-26T12:31:28Z [31690] ERROR at next (/usr/share/arangodb3/js/server/modules/@arangodb/foxx/router/tree.js:384:7)
2016-10-26T12:31:28Z [31690] ERROR at next (/usr/share/arangodb3/js/server/modules/@arangodb/foxx/router/tree.js:384:7)
2016-10-26T12:31:28Z [31690] ERROR at next (/usr/share/arangodb3/js/server/modules/@arangodb/foxx/router/tree.js:384:7)
However, the fixed JSON can be SUCCESSFULLY imported to the _SYSTEM database! 但是,固定的JSON可以成功导入到_SYSTEM数据库中! Thank you @mpv1989.
谢谢@ mpv1989。
It seems, persistence and import of the Queries snippets works only for the _SYSTEM DB... 看来,查询片段的持久性和导入仅适用于_SYSTEM DB。
What error message do you get when exporting/importing? 导出/导入时会收到什么错误消息?
For your workaround, I exported your query from the Web Interface. 为了解决此问题,我从Web界面导出了查询。 Here is the result:
结果如下:
[{
"name": "Create Random Complex Users (num, outpUsers)",
"value": "// Create specified number of users in the users Vertex collection\nFOR i IN 1..@usersNum\n INSERT {\n id: 100000 + i,\n age: 18 + FLOOR(RAND() * 50), // RAND generate float E {0, 1]\n name: CONCAT('user', TO_STRING(i))\n } IN @@users",
"parameter": {
"usersNum": 100,
"@users": "users"
}
}]
The field parameter
is a Json Object. field
parameter
是一个Json对象。 If you do not have any bind parameter just write an empty object "parameter": {}
. 如果您没有任何绑定参数,只需编写一个空对象
"parameter": {}
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.