express session - Error: Connection strategy not found MongoDB -


here simple connection use express session store, keeps banging out error though text right book. pretty sure has 'new mongostore' object initialization.

var express = require('express'),     expresssession = require('express-session');  var mongostore = require('connect-mongo/es5')(expresssession); var sessionstore = new mongostore({   host: '127.0.0.1',   port: '27017',   db: 'session' });  var app = express()     .use(expresssession({       secret: 'my secret sign key',       store: sessionstore      }))     .use('/home', function (req, res) {       if (req.session.views) {         req.session.views++;       }       else {         req.session.views = 1;       }       res.end('total views you:' + req.session.views);     })     .use('/reset', function(req, res) {       delete req.session.views;       res.end('cleared views');     })     .listen(3000); 

add url new mongostore()

  var sessionstore = new mongostore({         host: '127.0.0.1',         port: '27017',         db: 'session',         url: 'mongodb://localhost:27017/demo'     }); 

the code in question book beginning node.js by basarat ali syed.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -