首页 > 数据库 > NoSQL > mongo shell CURD
db.createCollection(<name>, { capped: <boolean>,
autoIndexId: <boolean>,
size: <number>,
max: <number>,
storageEngine: <document>,
validator: <document>,
validationLevel: <string>,
validationAction: <string>,
indexOptionDefaults: <document>,
viewOn: <string>,
pipeline: <pipeline>,
collation: <document>,
writeConcern: <document>} )
db.collection.insertMany(
[ <document 1> , <document 2>, ... ], ##这里是需要关系的,是一个document的集合
{
writeConcern: <document>,
ordered: <boolean>
})
db.test.find()
{ "_id" : ObjectId("5b48a1fe28317e2bbc2bf77b"), "name" : "hgs", "age" : 26 }
{ "_id" : ObjectId("5b48a26228317e2bbc2bf77c"), "name" : "hgs", "age" : 26 }
> db.test.updateMany({age:24},{$set:{name:"testse"}})
{ "acknowledged" : true, "matchedCount" : 1, "modifiedCount" : 1 }
例如:
> db.test.deleteOne({name:"testse"});
{ "acknowledged" : true, "deletedCount" : 1 }
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31506529/viewspace-2157854/ ,如需转载,请注明出处,否则将追究法律责任。