MongoDB表数据批量插入

for (var i = 200; i <210 ; i++) {
    db.getCollection("tb_table").insert({
        "level": NumberInt(1),
        "appTuid": "20230210-151329-8759-19227",
        "title": "自动化-0419-"+i,
        "content": "自动化-0419-"+i,
        "customParameters": "{'news_id': 134,'my_key': 'a value'}",
        "messageType": NumberInt(2),
        "sendTime": NumberLong("1683536622470"),
        "failSendCount": NumberInt(0),
        "sendState": NumberInt(1),
        "sendDesc": "待发送",
        "sendBody": "",
        "createBy": "20200917-134421-8819-97993",
        "createDate": NumberLong("1683536622470"),
        "updateBy": "20200917-134421-8819-97993",
        "updateDate": NumberLong("1683536622470"),
        "_class": "org.saic.dre.repository.message.model.device.AssignDeviceMessageEntity"
    })
}

  mongo也可用for循环实现数据批量插入

posted on 2023-05-11 18:00  波音666  阅读(251)  评论(0编辑  收藏  举报

导航