mongodb 數(shù)據(jù)生成Insert 語句的示例代碼
更新時間:2021年03月19日 11:45:54 作者:飛雪NET
這篇文章主要介紹了mongodb 數(shù)據(jù)生成Insert 語句的示例代碼,本文給大家介紹的非常詳細,對大家的學習或工作,具有一定的參考借鑒價值,需要的朋友可以參考下
執(zhí)行:
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 數(shù)據(jù)生成Insert 語句的示例代碼的文章就介紹到這了,更多相關mongodb生成Insert 語句內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
SpringBoot?整合mongoDB并自定義連接池的示例代碼
這篇文章主要介紹了SpringBoot?整合mongoDB并自定義連接池?,整合mongoDB的目的就是想用它給我們提供的mongoTemplate,它可以很容易的操作mongoDB數(shù)據(jù)庫,對整合過程及實例代碼感興趣的朋友跟隨小編一起看看吧2022-02-02
MongoDB數(shù)據(jù)庫查看慢查詢級別以及慢查詢日志
最近項目上一直在用mongodb作為數(shù)據(jù)庫,mongodb有他的優(yōu)勢,文檔型類json格式存儲數(shù)據(jù),修改起來更方便,但是最近在用mongodb出現(xiàn)了查詢緩慢的問題,這篇文章主要給大家介紹了關于MongoDB數(shù)據(jù)庫查看慢查詢級別以及慢查詢日志的相關資料,需要的朋友可以參考下2023-05-05

