How to Write a Write Concern

db.users.insert_one({“name”: name, “email”: email, “password”: hashedpw}, {writeConcern: {w: ‘majority’}})

I assumed that you can use similar syntax for write errors as shown in the lecture. But, when I tried to do the user preferences ticket, I kept getting the error below:

I then realized this was because my write concern was incorrect.

Thank you in advance.


Here are some code examples that show us how to bind write concern with operations. Hope it could help.

Q Yang