【发布时间】:2015-02-27 23:08:25
【问题描述】:
我有一个具有属性的对象。这包括一组具有自己属性的其他对象。
Lobby:
--> "a": "b"
--> "c": "d"
--> Players:[
--> 0
--> "x": "23"
--> "status": "ready"
--> 1
--> "x": "54"
--> "status": "open"
--> 2
--> "x": "16"
--> "status": "open"
如何将具有"status": "open"(在本例中为 1)的第一个播放器对象更新为新对象?
例如:
player = {
x: "125",
status: 'joined'
};
【问题讨论】:
-
(use $ op) in mongo shell db.collection.update( { _d : x, 'player.status' : 'open'}, { $set : {player.* : { //你的新玩家 } } }
-
@Disposer 我将如何在 Mongoose 中执行此操作?