ITPub博客

首页 > 数据库 > NoSQL > mongo shell CURD

mongo shell CURD

原创 NoSQL 作者:hgs19921112 时间:2018-07-13 21:21:37 0 删除 编辑
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>} )


Create Operations

     db.collection.insertOne()

     db.collection.insertMany()

                  

     The components of a MongoDB insertOne operations.

db.collection.insertMany(
   [ <document 1> , <document 2>, ... ], ##这里是需要关系的,是一个document的集合
   {
      writeConcern: <document>,
      ordered: <boolean>
   })

Read Operations

      

      

       db.test.find()

        { "_id" : ObjectId("5b48a1fe28317e2bbc2bf77b"), "name" : "hgs", "age" : 26 }

        { "_id" : ObjectId("5b48a26228317e2bbc2bf77c"), "name" : "hgs", "age" : 26 }

Update Operations

      

         The components of a MongoDB updateMany operation.


             

        > db.test.updateMany({age:24},{$set:{name:"testse"}})

        { "acknowledged" : true, "matchedCount" : 1, "modifiedCount" : 1 }

Delete Operations

The components of a MongoDB deleteMany operation.


    例如:

           

        > db.test.deleteOne({name:"testse"});

        { "acknowledged" : true, "deletedCount" : 1 }


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31506529/viewspace-2157854/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: rhel7 pgloader使用
请登录后发表评论 登录
全部评论

注册时间:2017-11-22

  • 博文量
    106
  • 访问量
    186399