Hello here is my problem,
var poolSchema = mongoose.Schema({
"topic_id": {
type: Number,
default: null,
required: true
},
"document_id": {
type: String,
default: null,
required: true
},
"project":{
type:String,
default: false,
required: true
},
"createddate":{
type:Date,
default : Date.now
}
}, { collection: "sorguHavuzu" });
i have an array of pool documents which each item has different field values such below :
var poolItems = [
{document_id :"FBIS3-50136" ,topic_id :"301" , project :"A1"},
{document_id :"LA040190-0178" ,topic_id :"302" , project :"A1"},
{document_id :"FT934-5418" ,topic_id :"303" , project :"A1"},
{document_id :"LA071090-0047" ,topic_id :"304" , project :"A1"}]
Here is my scheme :
I would like to upsert the items in the array by document_id field. So here is my update operation.
var query = {"document_id" : { $in:["FBIS3-50136","LA040190-0178","FT934-5418","LA071090-0047"]}};
Pools.collection.update(query, { $push : { "$ROOT" : poolItems } }, { upsert: true, multi : true}, callback);
Error: The dollar ($) prefixed field \'$ROOT\' in \'$ROOT\' is not valid for storage.
But on every attempt, i got different errors, is there a way to upsert items with mongoose update operation ? Thanks