voxpelli / node-connect-pg-simple

A simple, minimal PostgreSQL session store for Express
https://www.npmjs.com/package/connect-pg-simple
MIT License
234 stars 74 forks source link

pg-simples tries to access wrong column #294

Closed diegofariasm closed 10 months ago

diegofariasm commented 10 months ago

So, i am trying to setup a express session store with this:

import express, { Application, urlencoded, json } from 'express' import passport from './passport/passport' import session from 'express-session' import { pool } from './db/connection'

const pgSession = require('connect-pg-simple')(session);

const app: Application = express()

app.use(passport.initialize())

// Configure the session middleware.
app.use(
    session(
        {
            secret: env.SESSION_SECRET,
            saveUninitialized: false,
            store: new pgSession(
                {
                    pool: pool,
                }
            ),
            resave: false,
            proxy: true,
        }
    )
)
--\ snip \-- 

But then, when i try to login:

error: column "sess" of relation "session" does not exist
    at /home/fushiii/work/yaampa-project/node_modules/pg-pool/index.js:45:11
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PGStore._asyncQuery (/home/fushiii/work/yaampa-project/node_modules/connect-pg-simple/index.js:321:21)

Here's how my session schema looks like:

import { pgTable, varchar, date, json } from 'drizzle-orm/pg-core'

export const SessionSchema = pgTable('session', {
    sid: varchar('sid').primaryKey(),
    data: json('data'),
    expires: date('expires'),
})

export default SessionSchema
diegofariasm commented 10 months ago

My bad. After looking at table.sql that is located node_modues/connect-pig/simple, i found the right structure:

import { pgTable, varchar, date, json } from 'drizzle-orm/pg-core'

export const SessionSchema = pgTable('session', {
    sid: varchar('sid').primaryKey(),
    sess: json('sess'),
    expire: date('expire'),
})

export default SessionSchema