mongodb笔记1(基本操作,增删改)
> db.userInfo.insert({_id:1,name:"xiaoming"})WriteResult({ "nInserted" : 1 })
> db.userInfo.insert({_id:1,name:"xiaocang"})
WriteResult({
"nInserted" : 0,
"writeError" : {
"code" : 11000,
"errmsg" : "insertDocument :: caused by :: 11000 E11000 duplicate key error index: foobar.userInfo.$_id_dup key: { : 1.0 }"
}
})
> db.userInfo.save({_id:1,name:"xiaocang"})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
页:
[1]