Added drizzle orm
parent
d7d56025b9
commit
d167283c9c
@ -0,0 +1,14 @@
|
|||||||
|
import type { Config } from 'drizzle-kit'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
schema: './schema.ts',
|
||||||
|
out: './drizzle',
|
||||||
|
driver: 'pg',
|
||||||
|
dbCredentials: {
|
||||||
|
user: 'postgres',
|
||||||
|
password: 'password',
|
||||||
|
host: '0.0.0.0',
|
||||||
|
port: 5432,
|
||||||
|
database: 'next-dashboard',
|
||||||
|
},
|
||||||
|
} satisfies Config
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"version":"5","dialect":"pg","entries":[]}
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,38 @@
|
|||||||
|
import { relations } from 'drizzle-orm'
|
||||||
|
import {
|
||||||
|
pgTable,
|
||||||
|
serial,
|
||||||
|
text,
|
||||||
|
varchar,
|
||||||
|
timestamp,
|
||||||
|
integer,
|
||||||
|
} from 'drizzle-orm/pg-core'
|
||||||
|
|
||||||
|
export const user = pgTable('users', {
|
||||||
|
id: serial('id').primaryKey(),
|
||||||
|
name: text('name'),
|
||||||
|
email: text('email'),
|
||||||
|
password: text('password'),
|
||||||
|
createdAt: timestamp('created_at'),
|
||||||
|
updatedAt: timestamp('updated_at'),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const userRelations = relations(user, ({ many }) => ({
|
||||||
|
bookmark: many(bookmark),
|
||||||
|
}))
|
||||||
|
|
||||||
|
export const bookmark = pgTable('bookmarks', {
|
||||||
|
id: serial('id').primaryKey(),
|
||||||
|
userId: integer('user_id').references(() => user.id),
|
||||||
|
name: text('name'),
|
||||||
|
link: text('link'),
|
||||||
|
description: text('description'),
|
||||||
|
url: text('url'),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const bookmarkRelations = relations(bookmark, ({ one }) => ({
|
||||||
|
user: one(user, {
|
||||||
|
fields: [bookmark.userId],
|
||||||
|
references: [user.id],
|
||||||
|
}),
|
||||||
|
}))
|
||||||
Loading…
Reference in New Issue