maudulus
maudulus

Reputation: 11045

Error "Uncaught Error: When the modifier option is true, validation object must have at least one operator" when trying to update

I'm getting error message Uncaught Error: When the modifier option is true, validation object must have at least one operator

I've looked at a number of similar questions, but haven't been able to decipher what's wrong with my query:

Meteor.users.update({
    _id: Meteor.user()._id
}, {
    $set: {
        "emails.letter": true
    }
})

My MongoDB structure is as follows:

{
    "_id": "ujkwQp4rYTKQeLq3F",
    "emails": [{
        "address": "[email protected]",
        "letter": false
    }]
}

Upvotes: 1

Views: 279

Answers (1)

Brett McLain
Brett McLain

Reputation: 2010

You need to specify which element in the array you want to update. Try this:

Meteor.users.update({
    _id : 123456, 
    "emails.address":"[email protected]"
}, {
    $set: {
        "emails.$.letter": true
    }
});

Upvotes: 1

Related Questions