"cannot infer query fields to set"


#1

I have a basic upsert operation in my code:

      Follows.upsert({
        createdBy: 'me',
        entity: <some string value>,
        entityId: <an id>
      }, {
        $set: {
          createdBy: 'me',
          entity: <some string value>,
          entityId: <an id>
        }
      }, function(err, res) {
      ...
      }

However meteor is complaining cannot infer query fields to set, both paths 'entity' and 'entityId' are matched. Any clues what is going on here? Have there been changes in the latest meteor version changing the behaviour of upsert?


#2

If upsert needs to insert a new document (the query part is unmatched), it will use the values in the query part as the data to insert for those fields. If you’ve used different values in your $set (not clear in your question), there will be a conflict - how does it know which to use?


#3

Looks like I’m bitten by this bug: https://github.com/meteor/meteor/issues/9167