简单单个文档插入用插入方法:,
祝辞,db.post.insert({“酒吧”:“记者”}),,,,, WriteResult ({,“nInserted”: 1,})
,批量插入,用插入方法(参数要是一个文档数组):
祝辞,db.post.insert ([{" _id ": 0}, {" _id ": 1}, {" _id ": 2}]),,,, BulkWriteResult ({,,, ,,,,,,,,“writeErrors”:,,,,,,, ,,,,,,,,“writeConcernErrors”:,,,,,,, ,,,,,,,,“nInserted”:,,,,,, ,,,,,,,,“nUpserted”:, 0,,,,, ,,,,,,,,“nMatched”:, 0,,,,, ,,,,,,,,“nModified”:, 0,,,,, ,,,,,,,,“nRemoved”:, 0,,,,, ,,,,,,,“插入”,:,(,),,,, }),,,, 在
查看插入的结果:,
祝辞,db.post.find (),,,,, {," _id ": ObjectId (“54 a51cfd7f46906f81b7adcd”),“酒吧”,:,“记者”,},,,, {,“_id”: 0,},,,, {,“_id”: 1,},,,, {,“_id”: 2,},,,, 在