bartt / connect-session-mongo Goto Github PK
View Code? Open in Web Editor NEWMongoDB Session Storage for Connect Middleware
Home Page: https://github.com/bartt/connect-session-mongo
License: Other
MongoDB Session Storage for Connect Middleware
Home Page: https://github.com/bartt/connect-session-mongo
License: Other
In my dev environment, I have noticed warnings in my mongodb logs about a long-running query by _sessionId. This field is not indexed in the database, thus the entire collection has to be scanned. Granted, I could simply add an index. But why doesn't the software either enforce a unique index on _sessionId or store the session id in the _id field?
The _id field seems to be the most logical because it would avoid redundant data and it's guaranteed to be indexed. Performance aside, session id IS the unique id of a session object, so it makes sense semantically as well.
Excerpt from my mongodb server log.
Fri Aug 10 21:50:42 [conn25] query connect-sessions.sessions query: { _sessionid: "ArpwSnnfVozbOjdjpSh1HgIm.yLgebBiaNbTZWZ3I/sNanaCcq0zafccHWML9eTM4Ibk" } ntoreturn:1 nscanned:9 nreturned:1 reslen:453 967ms
Full warning text, displayed on new MongoStore()
call:
========================================================================================
= Please ensure that you set the default safe variable to one of the =
= allowed values of [true | false | {j:true} | {w:n, wtimeout:n} | {fsync:true}] =
= 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 false will change to true in the near future =
= =
= This message will disappear when the default safe is set on the driver Db =
========================================================================================
Connection is configured in the following way: mongo = require('mongoose').connect(MONGO_DB, {db: {safe: false}})
I have bad news I'm testing your application or em good mix of your aplicaicón improved .... But now I am showing
[ERROR] RangeError
[RangeError: Maximum call stack size exceeded]
The error is thrown at /connect-session-mongo.js:128
fn && fn();
The problem is that the clear
method takes no arguments, when it should take the fn
argument as a callback to be notified after removal or in case of error.
The problem is easily solved by adding the fn
argument to the clear
method. In connect-session-mongo.js:125:
MongoStore.prototype.clear = function() {
becomes
MongoStore.prototype.clear = function(fn) {
The same applies to the all
method, with the same solution; the other methods seem ok, but i didn't test them.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.