Node.js 在填充节点EJS MongoDB后获取数据
这是我的模式 我有这样的人口查询Node.js 在填充节点EJS MongoDB后获取数据,node.js,mongodb,population,Node.js,Mongodb,Population,这是我的模式 我有这样的人口查询 let population = [{model: Customer, path: 'customer'}, {model: Role, path: 'role', select: 'user', populate: {model: User, path: 'user'}}] "data": [ { "isactive": false, "created_at": "
let population = [{model: Customer, path: 'customer'}, {model: Role, path: 'role', select: 'user', populate: {model: User, path: 'user'}}]
"data": [
{
"isactive": false,
"created_at": "2020-01-20T07:57:36.251Z",
"_id": "5e255e7fe560893f0c30f9ce",
"code": "4",
"name": "DISTRIBUTOR 1",
"contact": "ronald",
"phone": 812117562425,
"email": "info@test.com",
"tipe": "A",
"__v": 0,
"customer": null,
"role": {
"_id": "5e255e96e560693f1c30f2cf",
"distributor_id": "5e255e2fe522083f0c30f9ce",
"user": {
"isactive": false,
"last_login": "2020-01-21T02:15:55.073Z",
"superUser": false,
"_id": "5e255fb6e560893f0c30f9d0",
"role_id": "5e255e96e560893f0c30f9cf",
"name": "yogi",
"description": "Admin1"
这个查询的结果是这样的
let population = [{model: Customer, path: 'customer'}, {model: Role, path: 'role', select: 'user', populate: {model: User, path: 'user'}}]
"data": [
{
"isactive": false,
"created_at": "2020-01-20T07:57:36.251Z",
"_id": "5e255e7fe560893f0c30f9ce",
"code": "4",
"name": "DISTRIBUTOR 1",
"contact": "ronald",
"phone": 812117562425,
"email": "info@test.com",
"tipe": "A",
"__v": 0,
"customer": null,
"role": {
"_id": "5e255e96e560693f1c30f2cf",
"distributor_id": "5e255e2fe522083f0c30f9ce",
"user": {
"isactive": false,
"last_login": "2020-01-21T02:15:55.073Z",
"superUser": false,
"_id": "5e255fb6e560893f0c30f9d0",
"role_id": "5e255e96e560893f0c30f9cf",
"name": "yogi",
"description": "Admin1"
我的问题是,如何在一个分发服务器中仅从每个角色获取用户数据?请在问题中包含相关的
模式,我的问题中包含了我的相关架构。您想查询哪个集合?我想查询分发服务器集合并获取一个分发服务器中的所有用户数据。但是您的分发服务器
集合与用户
没有任何直接关系,因此您无法代表分发服务器
获取用户
数据使用填充