Added drizzle orm

master
TZGyn 3 years ago
parent d7d56025b9
commit d167283c9c
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

@ -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":[]}

@ -29,12 +29,14 @@
"@types/react-dom": "18.2.4", "@types/react-dom": "18.2.4",
"autoprefixer": "10.4.14", "autoprefixer": "10.4.14",
"clsx": "^1.2.1", "clsx": "^1.2.1",
"drizzle-orm": "^0.28.1",
"eslint": "8.41.0", "eslint": "8.41.0",
"eslint-config-next": "13.4.4", "eslint-config-next": "13.4.4",
"framer-motion": "^10.12.16", "framer-motion": "^10.12.16",
"intl-messageformat": "^10.1.0", "intl-messageformat": "^10.1.0",
"next": "13.4.9", "next": "13.4.9",
"next-themes": "^0.2.1", "next-themes": "^0.2.1",
"pg": "^8.11.2",
"postcss": "8.4.24", "postcss": "8.4.24",
"react": "18.2.0", "react": "18.2.0",
"react-dom": "18.2.0", "react-dom": "18.2.0",
@ -43,6 +45,8 @@
"typescript": "5.0.4" "typescript": "5.0.4"
}, },
"devDependencies": { "devDependencies": {
"@types/pg": "^8.10.2",
"drizzle-kit": "^0.19.12",
"prettier": "^3.0.1", "prettier": "^3.0.1",
"prettier-plugin-tailwindcss": "^0.4.1" "prettier-plugin-tailwindcss": "^0.4.1"
} }

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,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "ES2015",
"lib": ["dom", "dom.iterable", "esnext"], "lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,

Loading…
Cancel
Save