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

Categories

假设MONGO文档中有xxoo(数组)和length(数组大小)两个字段。
不通过find.foreach(update)遍历的方式,如何更新length为xxoo数组的大小?
?示例文档:

{
    "_id": ObjectId("5f8554f49a8c7ff8d844555f"),
    "xxoo": ["x", "x", "o", "o"],
    "length": NumberInt("0")
    ……
}

?期望方法:
db.getCollection("xxx").update({'_id': '5f8554f49a8c7ff8d844555f'},{$set: {'length': {$size: $xxoo}})


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...