Miguel Morujão
Miguel Morujão

Reputation: 1161

Meteor - Updating user profile inside callback

I'm trying to update a user profile inside a callback, but I keep gettings the same error. Already tried multiple approaches.. Any help would be great. Thanks!

Exception in callback of async function: Error: Invalid modifier. Modifier must be an object.

        let user = Meteor.users.findOne({"profile.wallets.address": d.Address});
        let wallets = user.profile.wallets;
        wallets[0].amount = d.Amount;

        Meteor.users.update(user._id, {$set: {'profile.wallets': wallets}});

Upvotes: 1

Views: 77

Answers (1)

Mikkel
Mikkel

Reputation: 7777

Have you tried doing this:

let profile = user.profile
profile.wallets = wallets
Meteor.users.update(user._id, {$set: {profile: profile}})

Because maybe the modifier can't be a dotted path

Upvotes: 1

Related Questions