1. 程式人生 > >十三、mongodb之insert操作

十三、mongodb之insert操作

                           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 } ] );