node.js - NodeJS: Session store for Monk -


Looking at the needs of my project, I'm trying MeanJS, which uses Mongoos at the top of the MongoDB;

  var requires Mongostor = ('connect-mongo') (express); Var db = mongoose.connect ("localhost: ...", function (mistake) {}); App.use (session ({secret: 'foo', store: new mongostore ({db: db.connection.db}}}));  

How can I store sessions in my app using Monak, which other modules allow it to access?

You can use monk for your other Mango DDB behavior and to store sessions Still can use Connect-Mongo.

In Express 3.x (which looks like you're using on your code):

  var MongoStore = require ('connect-mongo' ) (Express), app. Use (session ({secret: 'afu', store: new mongostore ({url: 'mongodb: // localhost: 27017 / test'}}})));  

In this case, Monk is not really being used because Mongostor is making a new connection with DB. I tested it without the need for official Mongo driver or Monak.

All you need to do is run a Mongoode instance (in this case on the default port 27017).

You can refer to the Express code 4.x (which I use)

The method, the code is the same, but you have to install it and it will be Express-session modules will be required separately because it has not been packaged yet. Apart from this, there are two options which require the latest version of the Express session to be as clear as shown below.

  var session = is required ('express-session'), requires mongostore = ('Mongo') (session); App.use (session ({secret: 'foo', saveUninitialized: false, resave: false, store: new MongoStore ({url: 'mongodb: // localhost: 27017 / test'})})));  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -