Search code examples
meteormeteor-accounts

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}});

Solution

  • 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