Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
165 views
in Technique[技术] by (71.8m points)

mongodb 嵌套数组如何删除元素

{
    "_id" : ObjectId("5f5121e1e80f5003e84e3f02"),
    "name" : "五孔插座(",
    "bh" : "FIIWFWD",
    "id2" : "241231312312",
    "nid" : "xmfzr",
    "hs" : [ 
        [ 
            ISODate("2020-09-07T01:15:47.981Z"), 
            "asdsadas-11111"
        ], 
        [ 
            ISODate("2020-09-07T01:41:26.236Z"), 
            "12321343242-12sadasdasd"
        ], 
        [ 
            ISODate("2020-09-07T01:41:44.250Z"), 
            "dfdsf23432"
        ], 
        [ 
            ISODate("2020-09-07T01:41:53.585Z"), 
            "12312313dsadasd"
        ], 
        [ 
            ISODate("2020-09-07T21:41:42.708Z"), 
            "125565665"
        ], 
        [ 
            ISODate("2020-09-07T21:42:04.121Z"), 
            "32qqqqq"
        ], 
        [ 
            ISODate("2020-09-07T21:51:59.520Z"), 
            "12321312312"
        ], 
        [ 
            ISODate("2020-09-07T21:52:21.098Z"), 
            "213asdasdasdasdas"
        ]
       
    ]
}

想通过 ISODate("2020-09-07T01:41:26.236Z") 删除 hs 数组中的 第 1项 (这个数组),代码如何写
万分感谢???????????????


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

$pop 操作符,可以移除第一个或者最后一个数组元素。文档地址:https://docs.mongodb.com/manual/reference/operator/update/pop/#up._S_pop


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...