原本是使用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. POJ 3100 &amp; ZOJ 2818 &amp; HDU 2740 Root of the Problem(数学)

    题目链接: POJ:id=3100" style="font-size:18px">http://poj.org/problem? id=3100 ZOJ:http ...

  2. Basic脚本解释器移植到STM32

    本文来自http://blog.csdn.net/hellogv/ .引用必须注明出处! 上次讲了LUA移植到STM32.这次讲讲Basic脚本解释器移植到STM32. 在STM32上跑Basic脚本 ...

  3. MIT 操作系统实验 MIT JOS lab2

    MIT JOS lab2 首先把内存分布理清楚,由/boot/main.c可知这里把kernel的img的ELF header读入到物理地址0x10000处 这里能够回想JOS lab1的一个小问.当 ...

  4. HDU1698_Just a Hook(线段树/成段更新)

    解题报告 题意: 原本区间1到n都是1,区间成段改变成一个值,求最后区间1到n的和. 思路: 线段树成段更新,区间去和. #include <iostream> #include < ...

  5. Android开发有用技巧:推断当前系统语言版本号

    Locale locale = getResources().getConfiguration().locale; String language = locale.getLanguage(); 以上 ...

  6. Godaddy Drupal Update

    Godaddy对Drupal默认安装仅仅支持到7.22,眼下Drupal已经升级到7.28,安装完Drupal 7.22后,仅仅能手工升级. 安装Drupal在:https://hostingconn ...

  7. Haskell 几乎无疼痛入门指南

    当他重装Linux 机会虚拟机,安装 haskell 录制的过程中有什么.的方式来帮助那些谁在徘徊haskell进入外读者. 基本概念: Haskell : 是一门通用函数式语言.差点儿能够进行不论什 ...

  8. 返璞归真 asp.net mvc (3) - Controller/Action

    原文:返璞归真 asp.net mvc (3) - Controller/Action [索引页] [源码下载] 返璞归真 asp.net mvc (3) - Controller/Action 作者 ...

  9. java编程接口(6) ------ 图标

    本文提出了自己的学习笔记,欢迎转载,但请注明出处:http://blog.csdn.net/jesson20121020 能够在JLable或者不论什么从AbstractButton继承的组件使用Ic ...

  10. poj Firing(最大重量封闭图)

    Firing 题目: 要解雇一些人,而解雇的这些人假设人跟他有上下级的关系,则跟他有关系的人也要一起解雇.每一个人都会创造一定的价值,要求你求出在最大的获利下.解雇的人最小. 算法分析: 在这之前要知 ...