获取您自己的 Node 服务器
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://:27017/mydb";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  var dbo = db.db("mydb");
  //Insert 3 documents, with specified id values:
  var myobj = [
    { _id: 154, name: 'Chocolate Heaven'},
    { _id: 155, name: 'Tasty Lemon'},
    { _id: 156, name: 'Vanilla Dream'}
  ];
  dbo.collection("products").insertMany(myobj, function(err, res) {
    if (err) throw err;
    //Return the result object:
    console.log(res);
    db.close();
  });
});

              

{
  结果: { ok: 1, n: 3 },
  操作: [
    { _id: 154, name: '巧克力天堂 },
    { _id: 155, name: '美味柠檬 },
    { _id: 156, name: '香草之梦 } ],
  插入计数: 3,
  插入的 ID: [
    154,
    155,
    156 ]
}