3

I am using the mongoose module for my Express.js app, and I keep getting this error everytime I start up the app:

========================================================================================
=  Please ensure that you set the default write concern for the database by setting    =
=   one of the options                                                                 =
=                                                                                      =
=     w: (value of > -1 or the string 'majority'), where < 1 means                     =
=        no write acknowlegement                                                       =
=     journal: true/false, wait for flush to journal before acknowlegement             =
=     fsync: true/false, wait for flush to file system before acknowlegement           =
=                                                                                      =
=  For backward compatibility safe is still supported and                              =
=   allows values of [true | false | {j:true} | {w:n, wtimeout:n} | {fsync:true}]      =
=   the default value is false which means the driver receives does not                =
=   return the information of the success/error of the insert/update/remove            =
=                                                                                      =
=   ex: new Db(new Server('localhost', 27017), {safe:false})                           =
=                                                                                      =
=   http://www.mongodb.org/display/DOCS/getLastError+Command                           =
=                                                                                      =
=  The default of no acknowlegement will change in the very near future                =
=                                                                                      =
=  This message will disappear when the default safe is set on the driver Db           =
========================================================================================

I cannot figure out how to set the write concern. I am connecting to my database like this:

mongoose.connect('mongodb://localhost/reader')
2
  • Have you updated Mongoose to the latest? npm update mongoose
    – JohnnyHK
    Jan 25, 2013 at 18:22
  • That doesn't help unfortunately.
    – user1082754
    Jan 26, 2013 at 11:16

2 Answers 2

6

What you want to do is:

mongoose.connect('mongodb://localhost/reader', {db:{safe:false}})

That will give you the default behavior that existed before this whole explicit write concern thing happened in the mongo driver.

More information here: http://mongoosejs.com/docs/api.html#index_Mongoose-createConnection

3

It was because of the connect-mongodb package. I changed it to connect-mongo and this fixed the problem!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.