Stuck trying to update a field in a database

I have this JSON FILE

{
    "_id": "GgCRguT8Ky8e4zxqF",
    "services": {
    "emails": [
        {
            "address": "Abunae@naa.com",
            "verified": false,
            "verifiedMail": "Toto@hotmail.com"
        }
    ],
    "profile": {
        "name": "Janis"
    },
    "pushIds": []
}

I want to update my verifiedMail field but couldn’t figure out how to do it in Meteor, it’s always returning me an error

  let VerifiedEmail = "Exemple1"
   await Meteor.users.update({ _id: user._id }, { $set: { 'emails.verifiedEmail': emailRefactor} }, { upsert: true })

Couldn’t figure out how to access the emails.verifiedEmail field

Tried this exemlpe worked like a charm

let VerifiedEmail = "Exemple1"
   await Meteor.users.update({ _id: user._id }, { $set: { 'profile.name': emailRefactor} }, { upsert: true })

but couldn’t figure out how to access emails.verifiedEmail .

Could you please help me ?

Use this:

The Users database is special, don’t try to update anything besides the profile property directly.

Also: Your example didn’t work because you overlooked that the emails property is an array

Your query should have looked like this:

Meteor.users.update({_id: user.id}, {$set: {emails.0.verifiedEmail: emailRefactor} }, {upsert: true});

This would set the first array entry’s verifiedEmail attribute to what you want. But still, please use the built-in functions regardless.

This is throwing me an error, and even if i put emails.0.verifiedEmail between " " it’s creating a new field.

Say, I just told you to:

But still, please use the built-in functions regardless.

Couple of things:

Are you using the Meteor Accounts package? Cause I’ve never seen this field ‘verifiedMail’ before.

If you are using Meteor Accounts, as @rhywden mentioned, you should be using the built in function:
Accounts.addEmail(userId, newEmail, [verified])

Finally if you aren’t using Meteor Accounts, and don’t want to use the built in function, your issue may be a property typo. In your JSON file example the property is "verifiedMail", but in your update you have "verifiedEmail", so it’s going to create a new property.