Node.js 如何在环回中获取_id数据
我的数据库是arangodb。我想做的是:我有这样的数据:Node.js 如何在环回中获取_id数据,node.js,arangodb,Node.js,Arangodb,我的数据库是arangodb。我想做的是:我有这样的数据: _id:authModel/1209597 _key:1209597 { email: 'abc@gmail.com', password: 'password', subuser_ids:[ '811289', '1209611' ], id: '1209597' } _id:authModel/811289 _key:811289 { email: 'pqr@gmail.com', pa
_id:authModel/1209597
_key:1209597
{
email: 'abc@gmail.com',
password: 'password',
subuser_ids:[ '811289', '1209611' ],
id: '1209597'
}
_id:authModel/811289
_key:811289
{
email: 'pqr@gmail.com',
password: 'password',
id: '811289'
}
实际上,我需要获取数据,即子用户ID数组中的ID,即子用户ID包含2个ID。我需要获取子用户_id持有的数据。假设子用户id为“811289”,也就是说,我需要获取该数据。我正在使用arangodb和环回。我还编写了一个远程方法来访问该数据。我得到的是:
model.js
var server = require("../../server/server");
module.exports = function (Authmodel) {
Authmodel.on("attached", function () {
Authmodel.getApp(function (err, app) {
Authmodel.getSubUsers = function (params, cb) {
var result = [];
params.forEach(function (id) {
app.models.authModel.findOne({ "_id": id }, function (err, r) {
console.log("err", err);
console.log("r", r);
result.push(r);
});
})
cb(null, result);
};
});
});
Authmodel.remoteMethod('getSubUsers', {
accepts: { arg: 'params', type: 'array' },
returns: { arg: 'result', type: 'array' }
});
})
我在结果控制台中获得了日志,但数据不正确
我如何解决这个问题?我需要获取所有子用户ID数据。任何帮助都是值得感激和有益的