const updateResponse = await users.updateOne(
        { email: email },
        { $set: { preferences: preferences } },
        { upsert: true}

i am sending the params:
preferences: {favorite_cast: "Raj Kumar Hirani", preferred_language: "hindi"}

But Getting Error: An error occurred while updating this user's preferences, ReferenceError: someValue is not defined

someValue is the placeholder name put into the “template” function implementation. You would appear to have not actually deleted the original code when writing the new code.

Also, did the comments on the function tell you to use an upsert? If they don’t actually say it, then you probably should not be doing it. Remember that an upsert creates a new document when no other matching document to the condition is found. And if you think about the logic of the implementation, you probably don’t want that to happen here.


@neillunn in updateResponse function i have replaced someField , someValue with required values.

That error ( which is essentially a syntax error from the compiler ) says you have not changed what you think you have changed. Either that or this is no longer the error as you reported it but rather something else.

Check your code thoroughly and check that you are actually running the test you think you are running. If you have a different error than what you originally reported, then post that. But also please look things up on the wider internet first, as "ReferenceError" in a general search would have just told you exactly the same thing I did.

Thanx @neillunn was adding { upsert: true}, after removing my test passed!