jebas / connect-pg Goto Github PK
View Code? Open in Web Editor NEWPostgreSQL session store for Connect
License: MIT License
PostgreSQL session store for Connect
License: MIT License
this.getClient(function(err, client, done) {
if (err) return fn(err);
client.query('DELETE FROM ' + _this.table + ' WHERE sid = $2;', [ sid ], function(err) {
done();
if (err) return fn(err);
fn();
});
});
Postgres can't find $1 parameter and invoke error. If you replace $2 to $1 it will work.
Thanks.
As of version 1.0 of node-postgres, the pg.connect callback now returns a 'done' callback which one needs to use to return the client object to the connection pool.
var pg = require('pg');
function pgConnect (callback) {
pg.connect('tcp://nodepg:password@localhost/pgstore',
function (err, client, done) {
if (err) {
console.log(JSON.stringify(err));
}
if (client) {
callback(client);
done();
}
}
);
};
Hi there,
I'm using express.js in conjunction with connect-pg.
I want these sessions to expire within a reasonable amount of time, so I tried setting them to 1 hour, just for kicks.
app.use(express.session({
store: new pgStore(pgConnect),
maxAge : new Date(Date.now() + 3600000), //1 Hour
expires : new Date(Date.now() + 3600000), //1 Hour
secret: '@ky.jF8VBhR2[?tMqR9M6N4;Ek9b%tChxPtoTWFF'
}));
It seems that the maxAge and expires that are set in express are not honored in connect-pg.
Below is a sample row from the output from psql when I take a look at the contents of the session table
"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"
I believe it's a bug, but then again I'm new to node, so I could be missing something.
I already had a working code storing connect session to a noSQL backend. I wanted switch connect-pg. But each call generates a new session. What could be the reason? Seems everything works, even the data that I attached to the session is stored in the database, but each call generates a new session. Thanks.
What's the status of this project?
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.