Javascript Mongodb根据大量文档的少数条件将字段从一个集合添加到另一个集合
我遇到了以下情况,我需要经常更新大量集合 我有一个像下面这样的收藏Javascript Mongodb根据大量文档的少数条件将字段从一个集合添加到另一个集合,javascript,mongodb,mongoose,nodejs-server,Javascript,Mongodb,Mongoose,Nodejs Server,我遇到了以下情况,我需要经常更新大量集合 我有一个像下面这样的收藏 coll1 { "identification_id" : String, "name" : String, "mobile_number" : Number, "location" : String, "user_properties" : [Mixed types], "profile_url" : String } coll2 { "identification_id": String,
coll1
{
"identification_id" : String,
"name" : String,
"mobile_number" : Number,
"location" : String,
"user_properties" : [Mixed types],
"profile_url" : String
}
coll2
{
"identification_id": String,
"user_id" : String,
"name" : String,
"mobile_number" : Number,
"location" : String,
"user_properties" : String,
"profile_url": String,
"qualified_user" : String,
"user_interest_stage" :Number,
"source" : String,
"fb_id" : String,
"comments":String
}
updated coll1
{
"identification_id": String,
"name" : String,
"mobile_number" : Number,
"location" : String,
"user_properties" : String,
"profile_url": String,
"qualified_user" : String,
"user_interest_stage" :Number,
"source" : String,
"fb_id" : String,
"comments":String
}
正如您所看到的coll1和coll2,下面将插入文档场景
<--- JS stacktrace --->
==== JS stack trace =========================================
==JS堆栈跟踪=========================================
coll1中的文档数为1L。由于处理大量收集,我遇到了这种情况。所以我使用了skip和limit来处理所有文档,但处理所有文档花了1个小时
有没有更好的方法来处理这些类型的数据库更新以用于大量的集合?您试图一次保存太多的文档,这会导致内存不足 您有两个简单的选择:
--max old space size
标志,您可以手动设置脚本可以访问的内存量,如:节点--max old space size=4096 script.js