原本是使用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)的更多相关文章

  1. ubuntu mongodb报错:mongo - couldn't connect to server 127.0.0.1:27017

    在进入mongo的时候,出现在下面错误信息.那如何解决呢? 标记一下,以便下次理碰的到时候,有个参考. warning: Failed to connect to 127.0.0.1:27017, r ...

  2. mongoDB报错Cannot find module '../build/Release/bson'

    打算用nodejs写一个blog系统,发现nodejs还是存在很多的坑.在使用mongodb时遇到如下报错问题: { [Error: Cannot find module '../build/Rele ...

  3. springboot+mongodb报错Caused by: java.net.ConnectException: Connection refused (Connection refused)

    com.mongodb.MongoSocketOpenException: Exception opening socket at com.mongodb.connection.SocketStrea ...

  4. 启动mongodb报错,无法连接mongodb

    报错原因如下: MongoDB shell version v3.4.2 connecting to: mongodb://127.0.0.1:27017 --01T12:: W NETWORK [t ...

  5. sudo brew install mongodb报错

    报错信息如下: Error: Running Homebrew as root is extremely dangerous and no longer supported. As Homebrew ...

  6. 有关Gradle Network is unreachable: connect的报错

    项目Gradle   Errer:Network is unreachable: connect 同时还有as的 报错 Internal HTTP server disabled: Cannot st ...

  7. mongodb报错一例

    开发程序报错信息: Caused by: com.mongodb.MongoException: Executor error: OperationFailed: Sort operation use ...

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

    问题: 发现mongodb无法连接,查看mongodb日志,出现大量的如下报错: [initandlisten] connection refused because too many open co ...

  9. Kettle6.1连接MongoDB报错

    配置好mongodb连接之后,点击预览报下面的错: 报错: java.lang.NoClassDefFoundError: javax/crypto/spec/PBEKeySpec         a ...

随机推荐

  1. MVC区域 vs2013 mvc 搭建基架项

    http://www.it165.net/pro/html/201404/12822.html

  2. java实现xml文件CRUD

    java删除xml多个节点: 方案1.你直接改动了nodeList.这一般在做循环时是不同意直接这么做的. 你能够尝试在遍历一个list时,在循环体同一时候删除list里的内容,你会得到一个异常.建议 ...

  3. cocos2d-x3.0rc 版 设置模拟器窗体大小

    由于刚接触这职业时间不是非常长.也是第一次写博客,假设有错误的地方还请大神们指出,开通这博客目的非常easy相互学习和讨论(更重要的是记录工作中学到的东西以方便以后自己查阅) 先后參与过两个项目.只是 ...

  4. HttpClient文件上传下载

    1 HTTP HTTP 协议可能是如今 Internet 上使用得最多.最重要的协议了,越来越多的 Java 应用程序须要直接通过 HTTP 协议来訪问网络资源. 尽管在 JDK 的 java.net ...

  5. virtio-netdev 发送数据包

    在前面几文中已经大体介绍了virtio的重要组成,包含virtio net设备的创建,vring的创建,与virtio设备的交互方式.我们就从网络数据包的发送角度来看下virtio的详细使用流程. [ ...

  6. 【Android进阶】自定义控件实现底部扇形展开菜单效果

    这个项目是优化的其他人的,主要优化了界面菜单的显示,下面开始. 先看效果图 项目的总结构 下面开始贴代码,由于必要的地方都添加了注释,所以不过多讲解 anim_button.xml <?xml ...

  7. MySQL各种日期类型与整型(转)

    日期类型 存储空间 日期格式 日期范围 datetime 8 bytes YYYY-MM-DD HH:MM:SS 1000-01-01 00:00:00 ~ 9999-12-31 23:59:59 t ...

  8. Python日志输出格式和时间格式

    formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s","%Y%b%d-%H:%M:% ...

  9. 动软.NET 分页存储过程UP_GetRecordByPage

    1, ------------------------------------ --用途:支持任意排序的分页存储过程 --说明: ----------------------------------- ...

  10. fastjson初始化对性能的影响(转)

    之前在项目中序列化是用thrift,性能一般,而且需要用编译器生成新的类,在序列化和反序列化的时候感觉很繁琐,因此想转到json阵营.对比了jackson,gson等框架之后,决定用fastjson, ...