node.js连接mongodb数据库警告:(Please ensure that you set the default write concern)
启动node项目服务时出现: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 =
= 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 =
========================================================================================
的信息。虽然不影响测试但是还是存在安全问题的。
解决方法:
将数据的连接设置为安全的连接(在构建数据对象的地方):
module.exports = new Db(settings.db, new Server(settings.host, Connection.DEFAULT_PORT, {safe:true}),{safe:true});
添加上边红色字体可以解决。
版权声明:本文为博主原创文章,未经博主允许不得转载。
页:
[1]