哪位大侠来帮我看看这个问题
mongodb数据为: { “id” : ObjectId(“55d42b62676bda1c1c6a09ae”), “name” : “生活”, “description” : “生活需要大爆炸”, “type” : 1, “subtype” : [ ], “v” : 0 }
其数据结构为:
var typeScheMa = new ScheMa({
name: String,
description: String,
type:Number,
subtype:[{
name: String,
description: String,
type:Number
}]
});
现在我想新增subtype里面的记录,用mongose应该怎么写呢?
1 回复
Modelxxx.update({/* query condition*/}, {$push:{subtype: {/* new element */}, {/* options, like upsert */}, function(error, result) {});