Something’s not working for me with Meteor update.
If I run:
Countries.insert({name: 'China'});
I get a new document in my Countries collection, with name ‘China’ – as you’d expect.
But when I then run:
Countries.update({name: 'China'}, {population: '1 billion'});
The document now has a population property, but it’s lost its name property. It’s definitely the same document – same id.
I thought I was following this syntax:
collection.update(selector, modifier, [options], [callback])
straight out of the Meteor Docs.
I’ve also tried the update using the id string of the document (rather than the selector) in the update command, but the same thing happens.
What am I doing wrong?
Does this help
This adds the key:value if it doesn’t already exist for the doc. I have also successfully used the following to add a value to multiple docs.
This would add food:delicious to all countries with the continent Asia.