Reputation: 690
I'm trying to move Mongo document from one collection to another and I can't get it to work (in server method):
var oldData = newCollection.findOne({name: name});
if(oldData){
console.log(oldData); // this works
oldCollection.insert({oldData}); // this doesn't
}
Another way:
var oldData = newCollection.findOne({name: name});
if(oldData){
console.log(oldData.score); // this works
oldCollection.insert({
score: oldData.score
}); // this doesn't
What's wrong here?
Upvotes: 0
Views: 364
Reputation: 940
You shouldn't need the curly brackets in option 1 - oldCollection.insert(oldData)
Upvotes: 1