mongodb在文档

时间:2017-03-20 10:47:55

标签: mongodb mongodb-query

{

    "siteId" : "51",
    "thingId" : "0054",
    "Date" : 12345450,
    "unique" : [ 
        {
            "controller" : 12.0,
            "module" : 10.0,
            "variable" : "curent",
            "calculation" : [ 
                {
                    "min" : "",
                    "max" : "",
                    "avg" : "",
                    "cal" : [ 
                        {
                            "Datetime" : "",
                            "value" : 345.0
                        }, 
                        {
                            "Datetime" : "",
                            "value" : 312.0
                        }, 
                        {
                            "Datetime" : "",
                            "value" : 125.0
                        }
                    ]
                }
            ]
        }
    ],
    "thingType" : "",
    "moduleType" : 91.0,
    "enabled" : 1.0,
    "variableType" : "AI",
    "updatedTime" : NumberLong(1483209000),
    "requestedValue" : "",
    "requestedTime" : 0.0
}

在本文档中,我需要找到“cal”数组的“value”字段的main,max和avg,结果放在“计算”数组字段main,max和avg中,我该怎么做?

1 个答案:

答案 0 :(得分:0)

您可以在mongodb官方网站https://docs.mongodb.com/manual/reference/operator/

找到解决方案