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



原本是使用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‘
    })
    }))

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

时间: 2024-10-13 04:17:10

nodejs使用connect-mongodb报错(Please ensure that you set the default write concern)的相关文章

mongoDB报错Cannot find module &#39;../build/Release/bson&#39;

打算用nodejs写一个blog系统,发现nodejs还是存在很多的坑.在使用mongodb时遇到如下报错问题: { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson: Failed to load c++ bson extension, using pure JS version 折腾了一番,最后是这样解决的: 找到 npm 的module mongodb ..node_

brew安装mongodb报错Error: No available formula with the name &#39;mongodb&#39;

原因:MongoDB不再是开源的了,并且已经从Homebrew中移除 #43770 设定  $ brew tap mongodb/brew 安装 $ brew install [email protected]2     brew安装mongodb报错Error: No available formula with the name 'mongodb' 原文地址:https://www.cnblogs.com/zgaspnet/p/11769704.html

java连接mongodb报错

<span style="background-color: rgb(255, 255, 255); font-family: Arial, Helvetica, sans-serif;">写一个简短的测试程序却报错,郁闷</span> <span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"><

java连接MongoDB报错解决

报错内容 com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=127.0.0.1:27017, type=UNKN

mongodb报错:connection refused because too many open connections: 819

问题: 发现mongodb无法连接,查看mongodb日志,出现大量的如下报错: [initandlisten] connection refused because too many open connections: 819 mongodb的连接数到达819后,就无法增加,所以无法连接上去. 分析解决: 1.maxConns 限制 默认情况下,在Linux系统中,mongodb的最大连接数为819. 可以修改mongodb的最大连接数,修改其配置文件mongod.conf: maxConns

有关Gradle Network is unreachable: connect的报错

项目Gradle   Errer:Network is unreachable: connect 同时还有as的 报错 Internal HTTP server disabled: Cannot start internal HTTP server. Git integration, JavaScript debugger and LiveEdit may operate with errors. Please check your firewall settings and restart A

mongodb报错一例

开发程序报错信息: Caused by: com.mongodb.MongoException: Executor error: OperationFailed: Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit. 从程序报错中可以看到是排序的内存不足. 解决办法:3.x版本 use admin db.adminCommand({get

windows使用nvm安装nodejs后升级npm报错

新装一台电脑,安装nvm,使用nvm install安装nodejs,然后升级npm到特定版本 npm i -g [email protected]报错 怎么折腾都不成功.网上也没找到解决办法.后来我删掉nvm以及之前安装的nodejs.先去nodejs官网随便下载一个nodejs安装之后,再装nvm,勾选用nvm管理已安装的nodejs版本.然后再使用nvm安装新的nodejs版本以及升级npm就可以了,不会报错了.不明所以 原文地址:https://www.cnblogs.com/coder

liunx启动mongodb报错 mongodb child process failed, exited with error number 14

mongodb启动报错:mongodb child process failed, exited with error number 14,查看mongodb.cnf日志,发现其中有一条:Too many open files at src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp 79. 设置ulimit -n 10000.完美! 原文地址:https://www.cnblogs.com/shilang/p/1019748