时间:2021-03-20来源:www.pcxitongcheng.com作者:电脑系统城
执行:
1 2 3 |
db.getCollection('cap.published').find({}).forEach(function(item){ print( 'db.getCollection("cap.published").insert(' + tojson(item) + ');' ); }); |
返回结果:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
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 语句的示例代码的文章就介绍到这了
2023-03-15
Navicat远程连接MongoDB最全实现方法以及报错解决2023-03-15
MongoDB的启动方法详细总结2023-03-11
详解分库分表后非分片键如何查询GROUP BY 语句用于结合合计函数,根据一个或多个列对结果集进行分组,下面这篇文章主要给大家介绍了关于高版本Mysql使用group by分组报错的解决方案,文中通过实例代码介绍的非常详细,需要的朋友可以参考下...
2023-03-06