标签:style blog http color io os ar 使用 for
db.testData.insert({"name":"A","age":18})
for(var i = 19 ; i < 28 ; i++) {
db.testData.insert({"name":String.fromCharCode(i+47),"age":i})
}
db.testData.update({"name":"K"},{"name":"K","age":28})
db.testData.update({"name":"K"},{$inc:{"age":72}})
db.testData.update({"name":"K"},{$set:{"age":28}})
db.testData.update({"name":"L"},{"name":"L","age":29},true)
demo: db.testData.find({"age":{$gt:20}}) db.testData.find({"age":{$gte:20}}) db.testData.find({"age":{$lt:20}}) db.testData.find({"age":{$lte:20}}) db.testData.find({"age":{$ne:20}}) db.testData.find({"age":20})
demo: db.testData.find({$and:[{"name":"A","age":18}]}) db.testData.find({$or:[{"name":"A","name":"B"}]}) db.testData.find({"name":{$in:["A","B"]}}) db.testData.find({"name":{$nin:["A","B"]}})
db.testData.remove({})
db.testData.remove({"name":"A"})
本文原创博客地址:http://www.cnblogs.com/unofficial 官网地址: www.pushself.com
windows下mongodb基础玩法系列二CURD操作(创建、更新、读取和删除)
标签:style blog http color io os ar 使用 for
原文地址:http://www.cnblogs.com/unofficial/p/4030195.html