如何仅从Mongo文档中检索N个子文档

时间:2020-09-14 07:24:40

标签: node.js mongodb mongoose

MongoDB文档包含产品的历史价格。其结构如下:

{
    "pricehistory": {
        "2020-08-31T00:00:00": {
            "vendorA": 53532,
            "vendorB": 58787,
            "mdcomputers": 58929
        },
        "2020-08-30T00:00:00": {
            "vendorA": 36450,
            "vendorB": 39378,
            "vendorC": 54174
        },
        "2020-08-29T00:00:00": {
            "vendorA": 54308,
            "vendorB": 52188,
            "vendorC": 30349
        },
        "2020-08-28T00:00:00": {
            "vendorA": 30806,
            "vendorB": 44070,
            "vendorC": 39591
        },
        ..... 

    }
}

如何检索其属性大于“ 2020-08-01T00:00:00”的对象?该属性应该以ISODate格式保存吗?

0 个答案:

没有答案