Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 在填充节点EJS MongoDB后获取数据_Node.js_Mongodb_Population - Fatal编程技术网

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"


我的问题是,如何在一个分发服务器中仅从每个角色获取用户数据?

请在问题中包含相关的
模式,我的问题中包含了我的相关架构。您想查询哪个集合?我想查询分发服务器集合并获取一个分发服务器中的所有用户数据。但是您的
分发服务器
集合与
用户
没有任何直接关系,因此您无法代表
分发服务器
获取
用户
数据使用填充