Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 使用Mongoose时MongoDB写入问题_Node.js_Mongodb_Express_Mongoose - Fatal编程技术网

Node.js 使用Mongoose时MongoDB写入问题

Node.js 使用Mongoose时MongoDB写入问题,node.js,mongodb,express,mongoose,Node.js,Mongodb,Express,Mongoose,我正在为我的Express.js应用程序使用mongoose模块,每次启动应用程序时都会出现此错误: ======================================================================================== = Please ensure that you set the default write concern for the database by setting = = one of the option

我正在为我的Express.js应用程序使用mongoose模块,每次启动应用程序时都会出现此错误:

========================================================================================
=  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           =
========================================================================================

这是因为connect mongodb包。我将其更改为连接mongo,这解决了问题

这是因为connect mongodb包。我将其更改为连接mongo,这解决了问题

您要做的是:

mongoose.connect('mongodb://localhost/reader', {db:{safe:false}})
这将为您提供在mongo驱动程序中发生整个显式写关注事件之前存在的默认行为


此处的详细信息:

您要做的是:

mongoose.connect('mongodb://localhost/reader', {db:{safe:false}})
这将为您提供在mongo驱动程序中发生整个显式写关注事件之前存在的默认行为


此处的更多信息:

您是否已将Mongoose更新为最新版本?npm更新Mongoose不幸没有帮助。您是否已将Mongoose更新到最新版本?不幸的是,npm更新Mongooseth没有帮助。