目标是开发一个foxxservice
简单地以json
.
我已经尝试过:设置本地arangodb
服务器。然后阅读文档并使用arangosh
来尝试命令。然后扩展foxxservice
hello world 示例以获得相同的输出。
arangosh
127.0.0.1:8529@TestDatabase> db._collections()
[
[ArangoCollection 2393976, "_appbundles" (type document, status loaded)],
[ArangoCollection 2393973, "_apps" (type document, status loaded)],
[ArangoCollection 2393961, "_aqlfunctions" (type document, status unloaded)],
[ArangoCollection 2394097, "_fishbowl" (type document, status loaded)],
[ArangoCollection 2393964, "_frontend" (type document, status loaded)],
[ArangoCollection 2393943, "_graphs" (type document, status loaded)],
[ArangoCollection 2393970, "_jobs" (type document, status loaded)],
[ArangoCollection 2393948, "_modules" (type document, status loaded)],
[ArangoCollection 2393967, "_queues" (type document, status loaded)],
[ArangoCollection 2393951, "_routing" (type document, status loaded)],
[ArangoCollection 2394131, "Relation" (type edge, status loaded)],
[ArangoCollection 2394114, "Table" (type document, status loaded)]
]
狐狸服务:
'use strict';
const createRouter = require('@arangodb/foxx/router');
const db = require('@arangodb').db;
const router = createRouter();
module.context.use(router);
router.get('/hello-world', function (req, res) {
res.send('Hello World!');
const collections = db._collections();
res.json(collections);
})
.response(['application/json'], 'A generic greeting.')
.summary('Generic greeting')
.description('Prints a generic greeting.');
实际上,我期待相同的 json。希望出于安全原因,这不是不可能的。
但这就是浏览器显示的内容:
[
{"_id":"2393976","_dbName":"TestDatabase"},
{"_id":"2393973","_dbName":"TestDatabase"},
{"_id":"2393961","_dbName":"TestDatabase"},
{"_id":"2394097","_dbName":"TestDatabase"},
{"_id":"2393964","_dbName":"TestDatabase"},
{"_id":"2393943","_dbName":"TestDatabase"},
{"_id":"2393970","_dbName":"TestDatabase"},
{"_id":"2393948","_dbName":"TestDatabase"},
{"_id":"2393967","_dbName":"TestDatabase"},
{"_id":"2393951","_dbName":"TestDatabase"},
{"_id":"2394131","_dbName":"TestDatabase"},
{"_id":"2394114","_dbName":"TestDatabase"}
]