> 文章列表 > mongodb数据库的使用

mongodb数据库的使用

mongodb数据库的使用

1.安装

官网下载:Install MongoDB Community Kubernetes Operator | MongoDBDownload the MongoDB Community Kubernetes Operator for full control of MongoDB deployments from Kubernetes. Free for development.https://www.mongodb.com/try/download/community-kubernetes-operator

也可以下载6.0.5,不过下载6.0.5需要在下一个mongodb的shell连接器可以直接使用mongodb5.0.15的shell连接器

 

2.使用

MongoDB 概念解析 | 菜鸟教程

 启动mongodb服务

 连接mongodb服务

 

 3.mongoDb Shell下载安装与使用

Install mongosh — MongoDB Shell

4.插入

db.collection.insert() — MongoDB Manual

db.collection.insert()

db.collection.insert(
   <document or array of documents>,
   {
     writeConcern: <document>,
     ordered: <boolean>
   }
)

db.products.insert( { item: "card", qty: 15 } )

db.products.insert(
   [
     { _id: 11, item: "pencil", qty: 50, type: "no.2" },
     { item: "pen", qty: 20 },
     { item: "eraser", qty: 25 }
   ]
)

db.collection.insertOne() — MongoDB Manual

db.collection.insertOne()

db.collection.insertOne(
   <document>,
   {
      writeConcern: <document>
   }
)

db.products.insertOne( { item: "card", qty: 15 } );

db.collection.insertMany() — MongoDB Manual

db.collection.insertMany()

db.collection.insertMany(
   [ <document 1> , <document 2>, ... ],
   {
      writeConcern: <document>,
      ordered: <boolean>
   }
)

db.products.insertMany( [
      { item: "card", qty: 15 },
      { item: "envelope", qty: 20 },
      { item: "stamps" , qty: 30 }

] );

5.删除

持续更新中.....