[FEATURE]: Drizzle Session Store for `express-session`
Describe what you want
Suggestion to implement a Drizzle Store for express-session.
Basically, it should persist sessions on one of the tables defined using Drizzle.
Here is an example of Prisma Store.
any movement on this at all? All other major ORMs have this.
has anyone found an alternative?
This isn't something that Drizzle will provide first-party support for, since we don't provide tools for specific frameworks and its meant to be framework-agnostic. The Prisma store mentioned is a third-party package for Prisma; similarly, someone else can make a a third-party package supporting this use case.
@L-Mario564 holds a valid point.
For anyone working with a pg database you can just as easily use pgSession. In my case:
session.ts
import session from "express-session";
import pgSession from "connect-pg-simple"
import { pool } from "../db";
const pgStore = pgSession(session);
app.use(
session({
store: new pgStore({ pool, createTableIfMissing: true }),
// other options
})
);
db.ts
import { Pool } from "pg";
import { drizzle } from "drizzle-orm/node-postgres";
import schema from "./schema";
export const pool = new Pool({
host: process.env.DB_HOST,
port: Number(process.env.DB_PORT),
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
});
export const connect = async () => pool.connect();
const db = drizzle(pool, { schema });
export default db;