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],
|
||||||
|
}),
|
||||||
|
}))
|
||||||
@ -1,28 +1,28 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es5",
|
"target": "ES2015",
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"jsx": "preserve",
|
"jsx": "preserve",
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
"name": "next"
|
"name": "next"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./*"]
|
"@/*": ["./*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||||
"exclude": ["node_modules"]
|
"exclude": ["node_modules"]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue