欢迎来到代码驿站!

mongodb

当前位置:首页 > 数据库 > mongodb

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

时间:2021-10-22 09:09:01|栏目:mongodb|点击:

执行: 

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 认证鉴权你需要知道的一些事

栏    目:mongodb

下一篇:Java操作mongodb的模糊查询和精确查询

本文标题:mongodb 数据生成Insert 语句的示例代码

本文地址:http://www.codeinn.net/misctech/180903.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有