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