Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

connect-session-knex

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connect-session-knex - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

33

index.js

@@ -100,2 +100,3 @@ 'use strict';

self.tablename = options.tablename || 'sessions';
self.sidfieldname = options.sidfieldname || 'sid';
self.knex = options.knex || require('knex')({

@@ -113,3 +114,3 @@ client: 'sqlite3',

return self.knex.schema.createTable(self.tablename, function (table) {
table.string('sid').primary();
table.string(self.sidfieldname).primary();
table.json('sess').notNullable();

@@ -151,3 +152,3 @@ if (['mysql', 'mariasql'].indexOf(self.knex.client.dialect) > -1) {

.from(self.tablename)
.where('sid', '=', sid)
.where(self.sidfieldname, '=', sid)
.andWhereRaw(condition, dateAsISO(self.knex))

@@ -183,3 +184,3 @@ .then(function (response) {

sess = JSON.stringify(sess);
var postgresfastq = 'with new_values (sid, expired, sess) as (' +
var postgresfastq = 'with new_values (' + self.sidfieldname + ', expired, sess) as (' +
' values (?, ?::timestamp with time zone, ?::json)' +

@@ -190,17 +191,17 @@ '), ' +

' update ' + self.tablename + ' cs set ' +
' sid = nv.sid, ' +
' ' + self.sidfieldname + ' = nv.' + self.sidfieldname + ', ' +
' expired = nv.expired, ' +
' sess = nv.sess ' +
' from new_values nv ' +
' where cs.sid = nv.sid ' +
' where cs.' + self.sidfieldname + ' = nv.' + self.sidfieldname + ' ' +
' returning cs.* ' +
')' +
'insert into ' + self.tablename + ' (sid, expired, sess) ' +
'select sid, expired, sess ' +
'insert into ' + self.tablename + ' (' + self.sidfieldname + ', expired, sess) ' +
'select ' + self.sidfieldname + ', expired, sess ' +
'from new_values ' +
'where not exists (select 1 from upsert up where up.sid = new_values.sid)';
'where not exists (select 1 from upsert up where up.' + self.sidfieldname + ' = new_values.' + self.sidfieldname + ')';
var sqlitefastq = 'insert or replace into ' + self.tablename + ' (sid, expired, sess) values (?, ?, ?);';
var sqlitefastq = 'insert or replace into ' + self.tablename + ' (' + self.sidfieldname + ', expired, sess) values (?, ?, ?);';
var mysqlfastq = 'insert into ' + self.tablename + ' (sid, expired, sess) values (?, ?, ?) on duplicate key update expired=values(expired), sess=values(sess);';
var mysqlfastq = 'insert into ' + self.tablename + ' (' + self.sidfieldname + ', expired, sess) values (?, ?, ?) on duplicate key update expired=values(expired), sess=values(sess);';

@@ -236,3 +237,3 @@ var dbDate = dateAsISO(self.knex, expired);

.from(self.tablename)
.where('sid', '=', sid)
.where(self.sidfieldname, '=', sid)
.then(function (foundKeys) {

@@ -242,3 +243,3 @@ if (foundKeys.length === 0) {

.insert({
sid: sid,
[self.sidfieldname]: sid,
expired: dbDate,

@@ -249,3 +250,3 @@ sess: sess

return trx(self.tablename)
.where('sid', '=', sid)
.where(self.sidfieldname, '=', sid)
.update({

@@ -277,3 +278,3 @@ expired: dbDate,

return this.knex(this.tablename)
.where('sid', '=', sid)
.where(this.sidfieldname, '=', sid)
.andWhereRaw(condition, dateAsISO(this.knex))

@@ -301,3 +302,3 @@ .update({

.from(self.tablename)
.where('sid', '=', sid)
.where(self.sidfieldname, '=', sid)
.asCallback(fn)

@@ -317,3 +318,3 @@ });

return self.ready.then(function () {
return self.knex.count('sid as count')
return self.knex.count(self.sidfieldname + ' as count')
.from(self.tablename)

@@ -320,0 +321,0 @@ .then(function (response) {

{
"name": "connect-session-knex",
"description": "A knex.js session store for Express and Connect",
"version": "1.1.0",
"version": "1.2.0",
"main": "index.js",

@@ -25,11 +25,11 @@ "engines": {

"devDependencies": {
"bluebird": "^3.3.5",
"express": "^4.13.4",
"express-session": "^1.13.0",
"knex": "^0.11.1",
"mysql": "^2.10.2",
"pg": "^4.5.5",
"sqlite3": "^3.1.3",
"tape": "^4.5.1"
"bluebird": "^3.4.6",
"express": "^4.14.0",
"express-session": "^1.14.1",
"knex": "^0.12.2",
"mysql": "^2.11.1",
"pg": "^6.1.0",
"sqlite3": "^3.1.6",
"tape": "^4.6.2"
}
}

@@ -32,2 +32,3 @@ # Connect Session Knex

- `tablename='sessions'` Tablename to use. Defaults to 'sessions'.
- `sidfieldname='sid'` Field name in table to use for storing session ids. Defaults to 'sid'.
- `knex` knex instance to use. Defaults to a new knex instance, using sqlite3 with a file named 'connect-session-knex.sqlite'

@@ -34,0 +35,0 @@ - `createtable` if the table for sessions should be created automatically or not.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc