UNPKG

@coursebuilder/adapter-drizzle

Version:

Drizzle adapter for Course Builder.

48 lines (46 loc) 1.21 kB
import { getUsersSchema } from "./chunk-LPJ2P2KJ.js"; import { __name } from "./chunk-H736K5TN.js"; // src/lib/mysql/schemas/auth/sessions.ts import { relations } from "drizzle-orm"; import { index, timestamp, varchar } from "drizzle-orm/mysql-core"; function getSessionsSchema(mysqlTable) { return mysqlTable("Session", { sessionToken: varchar("sessionToken", { length: 255 }).notNull().primaryKey(), userId: varchar("userId", { length: 255 }).notNull(), expires: timestamp("expires", { mode: "date" }).notNull() }, (session) => ({ userIdIdx: index("userId_idx").on(session.userId) })); } __name(getSessionsSchema, "getSessionsSchema"); function getSessionRelationsSchema(mysqlTable) { const sessions = getSessionsSchema(mysqlTable); const users = getUsersSchema(mysqlTable); return relations(sessions, ({ one }) => ({ user: one(users, { fields: [ sessions.userId ], references: [ users.id ], relationName: "user" }) })); } __name(getSessionRelationsSchema, "getSessionRelationsSchema"); export { getSessionsSchema, getSessionRelationsSchema }; //# sourceMappingURL=chunk-PBTEHA7F.js.map