As you are developing applications, on occasion, you will run into a situation where you need to either update an existing record, or insert a record if it doesn't exist already. This is done traditionally using conditional operators such as
Through MongoDB, Meteor removes the burden of checking by allowing you to upsert (update + insert) records using a simple syntax. This recipe will show you how.
We will again use the project created in the Sorting with MongoDB queries recipe, found in this chapter. Please create a fresh copy of this recipe, and use the files as a baseline for this recipe.
We will also be using the official
momentjs package. To add the
momentjs package, navigate to your project's ...