[SOLVED] Calling update to update a field on a user sends the user with all undefined values to the client

If I call on the database db.users.update({_id: userId}, {$set: {anyField: value}});, for the currently logged in user, the client receives an update of that user document with all fields set as undefined except for the _id field, like this:

{
    _id: userId,
    emails: undefined,
    username: undefined,
    etc...
}

and then the client re-logs in to receive the correct fields.

Does anyone know why Meteor does this?

what does the record look like after you updated it?
normally you don’t call db.users.update. I guess you use other database manager program to update your data?

Thanks for the answer. I just found the issue. I was using a remote MongoDB Atlas cluster in version 5.0.9 and my Meteor version was 5.2.3, which supports MongoDB 4.6. Updating to Meteor 2.7.3, which supports MongoDB 5.0 solved the issue. The old driver was messing things up badly.

3 Likes