首页 > 数据库 > MongoDB

mongodb 数据生成Insert 语句的示例代码

admin MongoDB 2022-02-10 12:20:50 mongodb生成Insert   语句   mongodb   Insert   语句"

执行: 

db.getCollection('cap.published').find({}).forEach(function(item){
    print( 'db.getCollection("cap.published").insert(' + tojson(item) + ');' );
});

返回结果:

db.getCollection("cap.published").insert({
	"_id" : NumberLong("1102078858484363264"),
	"Name" : "order.rabbitmq.mongodb",
	"Content" : "{\"Id\":\"5c7b668a61ff69508c6804e4\",\"Timestamp\":\"2019-03-03T13:30:50.1988102+08:00\",\"Content\":\"2019/3/3 13:30:50\",\"CallbackName\":null}",
	"Added" : ISODate("2019-03-03T05:30:50.151Z"),
	"ExpiresAt" : null,
	"Retries" : 0,
	"StatusName" : "Scheduled",
	"Version" : "v1"
});
db.getCollection("cap.published").insert({
	"_id" : NumberLong("1102079247510253568"),
	"Name" : "order.rabbitmq.mongodb",
	"Content" : "{\"Id\":\"5c7b66e661ff69508c6804e7\",\"Timestamp\":\"2019-03-03T13:32:22.9051009+08:00\",\"Content\":\"2019/3/3 13:32:22\",\"CallbackName\":null}",
	"Added" : ISODate("2019-03-03T05:32:22.905Z"),
	"ExpiresAt" : null,
	"Retries" : 0,
	"StatusName" : "Scheduled",
	"Version" : "v1"
});
db.getCollection("cap.published").insert({
	"_id" : NumberLong("1102080584656740352"),
	"Name" : "order.rabbitmq.mongodb",
	"Content" : "{\"Id\":\"5c7b682561ff692e5cdee269\",\"Timestamp\":\"2019-03-03T13:37:41.9368025+08:00\",\"Content\":\"2019/3/3 13:37:41\",\"CallbackName\":null}",
	"Added" : ISODate("2019-03-03T05:37:41.699Z"),
	"ExpiresAt" : null,
	"Retries" : 0,
	"StatusName" : "Scheduled",
	"Version" : "v1"
});
db.getCollection("cap.published").insert({
	"_id" : NumberLong("1102081814329499648"),
	"Name" : "order.rabbitmq.mongodb",
	"Content" : "{\"Id\":\"5c7b694a61ff69321cd19bc4\",\"Timestamp\":\"2019-03-03T13:42:34.933565+08:00\",\"Content\":\"2019/3/3 13:42:34\",\"CallbackName\":null}",
	"Added" : ISODate("2019-03-03T05:42:34.879Z"),
	"ExpiresAt" : null,
	"Retries" : 0,
	"StatusName" : "Scheduled",
	"Version" : "v1"
});
db.getCollection("cap.published").insert({
	"_id" : NumberLong("1102082932053180416"),
	"Name" : "order.rabbitmq.mongodb",
	"Content" : "{\"Id\":\"5c7b6a5561ff692ef44a8c2b\",\"Timestamp\":\"2019-03-03T13:47:01.4290666+08:00\",\"Content\":\"2019/3/3 13:47:01\",\"CallbackName\":null}",
	"Added" : ISODate("2019-03-03T05:47:01.366Z"),
	"ExpiresAt" : null,
	"Retries" : 0,
	"StatusName" : "Scheduled",
	"Version" : "v1"
});

到此这篇关于mongodb 数据生成Insert 语句的示例代码的文章就介绍到这了,更多相关mongodb生成Insert 语句内容请搜索潘少俊衡以前的文章或继续浏览下面的相关文章希望大家以后多多支持潘少俊衡!

版权声明

本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。
本文地址:/shujuku/MongoDB/104216.html

留言与评论(共有 0 条评论)
   
验证码:

潘少俊衡

| 桂ICP备2023010378号-4

Powered By EmpireCMS

爱享小站

中德益农

谷姐神农

环亚肥料

使用手机软件扫描微信二维码

关注我们可获取更多热点资讯

感谢潘少俊衡友情技术支持