猫鼬使用3级阵列填充

时间:2018-09-18 14:02:56

标签: mongodb mongoose

我是mongodb和mongoose的新手,最近开始从事一个已经存在的项目。我在从订单集合中获取产品详细信息时遇到了问题,因为我研究填充时会用猫鼬从其他集合中获取动态数据的方法,因此我尝试实现它,但能够理解,因为填充会在结构I中起作用有。下面是我的订单表的数据库结构

{
    "_id": {
        "$oid": "5b9d0fb87c0a8700040a9712"
    },
    "cartobject": [
        {
            "_5b93848db79f8100048948c1_PARINDA_30": {
                "_id": "5b93848db79f8100048948c1",
                "sku": "1006",
                "brandSerialNumber": "45",
                "quantity": 5,
                "productName": "DESI TOOR DALL (SAWA NO.)",
                "brand": "PARINDA",
                "pack": {
                    "packvalue": "30",
                    "totpack": "30",
                    "innerpack": "1",
                    "packcharges": "0"
                },
                "price": 5200,
                "brandPrice": "5200",
                "offerMaxKgLimit": 0,
                "qtyInKg": 150,
                "deliveredQty": 0,
                "balanceQty": 5,
                "offer": 0,
                "offerPrice": "5200",
                "staticOfferPrice": 5200,
                "offerId": null,
                "fullOffer": null,
                "discountOnQuantity": 0,
                "staticDiscountOnQuantity": 0,
                "transportCharge": 40,
                "transportRate": 8,
                "totalItemPrice": 7840
            }
        }
    ],
    "orderdate": {
        "$date": "2018-09-15T19:27:10.000Z"
    },
    "customername": "User One 1111",
    "brokername": "Test",
    "amount": 7880,
    "orderid": 1537019823579,
    "ordernote": "",
    "userid": {
        "$oid": "5b50375de1b8d4000485ffd6"
    },
    "transportcharge": 40,
    "ordermilisecond": 1537019830006,
    "customernumber": null,
    "brokernumber": null,
    "__v": 0
}

这是我的产品系列的结构

{
    "_id": {
        "$oid": "5b93848db79f8100048948c1"
    },
    "productbrand": [
        {
            "serialnumber": "45",
            "productbrand": "PARINDA",
            "brand_pack_variation": [
                {
                    "packvalue": "30",
                    "totpack": "30",
                    "innerpack": "1",
                    "packcharges": "0"
                }
            ]
        }
    ],
    "creationdate": {
        "$date": "2018-09-08T08:13:01.930Z"
    },
    "producttitle": "DESI TOOR DALL (SAWA NO.)",
    "productbody": "DESI SAWA NO.",
    "sku": "1006",
    "unit": "QTL",
    "datemiliseconds": 1536394381930,
    "regularprice": 5200,
    "brandprice": {
        "PARINDA": "5200"
    },
    "ratechangedate": "08/09/2018",
    "__v": 0,
    "brandpricediff": {
        "PARINDA": "0"
    }
}

任何人都可以告诉我,在这里可以使用哪种方式填充,以便在cartobject数组中代替"_id": "5b93848db79f8100048948c1"来获得动态产品对象。请帮我,因为没有与查询相关的答案。我已经尝试了一切

0 个答案:

没有答案