Meteor upsert equivalent

后端 未结 3 1744
遥遥无期
遥遥无期 2021-01-01 03:57

How soon will the upsert command be implemented in Meteor?

And, what is the best way to do the same thing in the mean time?

Something like this is what I\'m

3条回答
  •  旧巷少年郎
    2021-01-01 04:36

    Upsert is really easy with this trick. you just check if it has an _id property:

    if(item._id){
      //update
    }else{
      //insert
    }
    

提交回复
热议问题