I have been trying to figure this out for over two days now, and just do not understand the error (or lack of) that Mongo is giving me. I am using Node.js.
This is also a valid syntax to check the condition,
You need to take care of the below point and check by yourself,
The case-sensitivity matters so make sure the database name is correct in your connection, and the collection name is in your model declaration, fields/properties name in your schema and query, should be in exact same case that you have in your database.
Make sure the “userId”: “100” should be in string “100” not in number 100, both are different
Make sure the “guildId”: “1” should be in string “1” not in number 1, both are different
After three days of trying to solve this, I am giving up on trying to use the mongoose schema to do this. I am now getting an error saying "Cannot create field ‘guildId’ in element. So for anyone else reading this, give up now and save yourself three days.
I created a new function that connects to the database using the MongoDB library, and update the database that way.