mongodb之insert操作


插入操作运算符:

运算符 含义
db.collection.insertOne() 插入一个文档
db.collection.insertMany() 插入多个文档
db.collection.insert() 插入一个或者多个



db.products.insertOne( { _id: 10, "item" : "packing peanuts", "qty" : 200 } );

db.products.insert( { _id: 10, item: "box", qty: 20 } )

db.products.insertMany( [
      { _id: 14, item: "envelopes", qty: 60 },
      { _id: 15, item: "stamps", qty: 110 },
      { _id: 16, item: "packing tape", qty: 38 }
   ] );