Chris Kraszewski
Chris Kraszewski

Reputation: 690

Meteor - move data from one collection to another

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

Answers (1)

Philip Pryde
Philip Pryde

Reputation: 940

You shouldn't need the curly brackets in option 1 - oldCollection.insert(oldData)

Upvotes: 1

Related Questions