O'Reilly logo

Meteor: Full-Stack Web Application Development by Marcelo Reyna, Isaac Strack, Fabian Vogelsteller

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating upsert MongoDB queries

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 if.

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.

Getting ready

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required