如何检查$存在一对多关系mongodb sails js?

时间:2018-04-10 13:00:49

标签: mongodb sails.js

有没有办法找到集合为空的记录?

例如,请在下面找到数组。我只希望索引为“companydata”的记录为空。以及如何获得没有空“companydata”数据的数据。

提前致谢。

[
{
    "company_id": {
        "company_name": "C2",
        "slug": "c2",
        "is_organized": 1,
        "status": "1",
        "id": "5adf158f547f7f0314ca8b56",
        "companydata": []
    },
    "user_id": "5ab889aee74a151b50d04ec1",
    "status": "0",
    "id": "5ae014e7432e85298081be0b"
},
{
    "company_id": {
        "company_name": "My Compnay",
        "slug": "my-compnay",
        "is_organized": 1,
        "status": "1",
        "id": "5ad442d98a0e0c1358ca93df",
        "companydata": [
            {
                "name": "Bhavesh Amin",
                "company_id": "5ad442d98a0e0c1358ca93df",
                "status": "0",
                "id": "5ad442da8a0e0c1358ca93e0"
            }
        ]
    },
    "user_id": "5ab889aee74a151b50d04ec1",
    "status": "0",
    "id": "5ae01388432e85298081bdf8"
},
{
    "company_id": {
        "company_name": "Organization Name",
        "slug": "organization-name",
        "is_organized": 1,
        "status": "1",
        "id": "5ad08f9b938d1131eceea624",
        "companydata": [
            {
                "name": "Helen H. Langley",
                "company_id": "5ad08f9b938d1131eceea624",
                "status": "1",
                "id": "5ad08f9b938d1131eceea625"
            }
        ]
    },
    "user_id": "5ab889aee74a151b50d04ec1",
    "status": "0",
    "id": "5ad42a5f52851a2b1449db2d"
},

0 个答案:

没有答案