connect-session-knex icon indicating copy to clipboard operation
connect-session-knex copied to clipboard

Mistake in PostGreSQL example?

Open alandsidel opened this issue 1 year ago • 0 comments

This code is adapted from the example at https://github.com/gx0r/connect-session-knex/blob/main/examples/example-postgres.mjs but results inthe error Cannot find module 'sqlite3' in node_modules/connect-session-knex/dist/index.js:26:36

'use strict';

import pg from 'pg';
import knex from 'knex';
import { ConnectSessionKnexStore } from 'connect-session-knex';
import consts from './consts.cjs';

const db = knex({
  client: 'pg',
  connection: {
    host: consts.DB_HOST,
    port: consts.DB_PORT,
    user: consts.DB_USER,
    password: consts.DB_PASS,
    database: consts.DB_DB
  },
  searchPath: consts.DB_SCHEMA
});

const sessionStore = new ConnectSessionKnexStore({
  db,
  tablename: 'sessions'
});

It appears that this is because ConnectSessionKnexStore needs the knex instance to be in a key named knex, not simply on it's own as above in the sessionStore var, and changing db, to knex: db, does appear to solve the issue. Is this just a mistake in the example that needs corrected?

alandsidel avatar Jul 17 '24 20:07 alandsidel