我在 mongodb 数据库中有两个集合,每个集合都有模型
应用模型
module.exports = {
tableName: 'app',
attributes: {
_id : {
primaryKey: true,
unique: true,
type: 'string',
},
userId: {
model: 'user'
},
title: {
type: 'string',
required: true,
unique: true,
},
createdDate : 'string'
},
};
和用户模型
module.exports = {
tableName: 'user',
attributes: {
id : {
primaryKey: true,
unique: true,
type: 'string',
collection: "app",
via : "userId"
},
password: {
type: 'string',
required: true
},
apps : {
collection: "app",
via : "userId"
}
},
};
当我使用数值加入此集合时,它工作正常,但是当我尝试使用 mongodb 本机 id 对象时,我得到空结果
我如何调用连接查询
User.find().populate('apps').exec(function(err, result) {});