Reputation: 1451
"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:
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.
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)
Using the JSON fixed by @mpv1989 the following error appears in the 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:
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! Thank you @mpv1989.
It seems, persistence and import of the Queries snippets works only for the _SYSTEM DB...
Upvotes: 0
Views: 165
Reputation: 1891
What error message do you get when exporting/importing?
For your workaround, I exported your query from the Web Interface. 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. If you do not have any bind parameter just write an empty object "parameter": {}
.
Upvotes: 1