简体   繁体   English

流星-将数据从一个集合移到另一个

[英]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): 我正在尝试将Mongo文档从一个集合移动到另一个集合,但无法使其正常工作(在服务器方法中):

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? 怎么了

您不需要在选项1中使用大括号oldCollection.insert(oldData)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM