这两个mongodb插入语句如何不同

时间:2016-05-10 10:17:09

标签: mongodb

我想在mongodb中插入一个嵌套对象,并将第一个代码插入数据库

;db.told.insert({ 
name: "admin", 
status: "online",
catalog : [
    {
        "objectid" : ObjectId().str,
        "message" : "sold",
        "status" : "open"
    }]
})

但这不是

  db.told.insert({
     communicationtype:"sms",
    communicationmessage:[{
                        "objectid" : ObjectId().str,
                        "1" : "House",
                        "2" : "Flat",
                        "3" : "Bungalow",
                        "4" : "Maisonette"
                    }],
    communicationsenton:"a",
    communicationsentby:"b",
    communicationstatus:"sent"
            })

为什么第二个语句没有插入?

0 个答案:

没有答案