码迷,mamicode.com
首页 > 数据库 > 详细

nodejs使用connect-mongodb报错(Please ensure that you set the default write concern)

时间:2015-06-28 11:20:38      阅读:514      评论:0      收藏:0      [点我收藏+]

标签:mongodb   nodejs   


原本是使用connect-mongo的,可能是express版本的升级报错了,改用connect-mongodb,但是使用后出现了如下的警告:

G:\nodejs\moviesite>grunt
Running "concurrent:tasks" (concurrent) task
    Running "nodemon:dev" (nodemon) task
    Running "watch" task
    Waiting...
    [nodemon] v1.3.7
    [nodemon] to restart at any time, enter `rs`
    [nodemon] watching: *.*
    [nodemon] starting `node app.js`
    ============================================================================
============
    =  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 acknowledgement
            =
    =     journal: true/false, wait for flush to journal before acknowledgement
            =
    =     fsync: true/false, wait for flush to file system before acknowledgemen
t           =
    =
           =
    =  For backward compatibility safe is still supported and
           =
    =   allows values of [true | false | {j:true} | {w:n, wtimeout:n} | {fsync:t
rue}]      =
    =   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 acknowledgement will change in the very near future
            =
    =
           =
    =  This message will disappear when the default safe is set on the driver Db
           =
    ============================================================================
============
Sat, 27 Jun 2015 12:49:12 GMT express-session deprecated undefined resave option
; provide resave option at app.js:20:9
Sat, 27 Jun 2015 12:49:12 GMT express-session deprecated undefined saveUninitial
ized option; provide saveUninitialized option at app.js:20:9
    moviesite started on port 3000

下边的警告在session中添加两个属性值restart和saveUninitialized即可解决。

Sat, 27 Jun 2015 12:49:12 GMT express-session deprecated undefined resave option
; provide resave option at app.js:20:9
Sat, 27 Jun 2015 12:49:12 GMT express-session deprecated undefined saveUninitial
ized option; provide saveUninitialized option at app.js:20:9

如:
    app.use(session({
    resave: false,//重新保存:强制会话保存即使是未修改的。(默认值ture)
    saveUninitialized: true,//强制保存未初始化的会话到存储器
    cookie: {maxAge:3600000}, 
    secret:‘imooc‘,
    store:new mongoStore({
        url:dbUrl,
        collection:‘sessions‘
    })
    }))

剩下的警告应该是数据库不是安全连接,还未能解决,知道的朋友告诉一下

nodejs使用connect-mongodb报错(Please ensure that you set the default write concern)

标签:mongodb   nodejs   

原文地址:http://blog.csdn.net/allgis/article/details/46664243

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!