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 语句内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551.com!

(0)
上一篇 2022年3月21日
下一篇 2022年3月21日

相关推荐