lint code

Signed-off-by: Arthur DANJOU <arthurdanjou@outlook.fr>
This commit is contained in:
2024-04-20 00:18:43 +02:00
parent c6ba8c791b
commit c698bfec8a
44 changed files with 180 additions and 177 deletions

View File

@@ -1,5 +1,5 @@
import { boolean, date, integer, pgEnum, pgTable, primaryKey, serial, text, timestamp } from 'drizzle-orm/pg-core'
import { relations } from 'drizzle-orm'
import {boolean, date, integer, pgEnum, pgTable, primaryKey, serial, text, timestamp} from 'drizzle-orm/pg-core'
import {relations} from 'drizzle-orm'
// O B J E C T S
@@ -9,13 +9,13 @@ export const maintenances = pgTable('maintenances', {
enabled: boolean('enabled').default(false).notNull(),
beginAt: date('begin_at').defaultNow().notNull(),
endAt: date('end_at').defaultNow().notNull(),
createdAt: timestamp('created_at').defaultNow().notNull()
createdAt: timestamp('created_at').defaultNow().notNull(),
})
export const announcements = pgTable('announcements', {
id: serial('id').primaryKey(),
content: text('content').default('').notNull(),
createdAt: timestamp('created_at').defaultNow().notNull()
createdAt: timestamp('created_at').defaultNow().notNull(),
})
export const posts = pgTable('posts', {
@@ -23,7 +23,7 @@ export const posts = pgTable('posts', {
slug: text('slug').notNull(),
likes: integer('likes').default(0).notNull(),
views: integer('views').default(0).notNull(),
createdAt: timestamp('created_at').defaultNow().notNull()
createdAt: timestamp('created_at').defaultNow().notNull(),
})
export const suggestions = pgTable('suggestions', {
@@ -32,9 +32,9 @@ export const suggestions = pgTable('suggestions', {
content: text('content').notNull(),
added: boolean('added').default(false).notNull(),
createdAt: timestamp('created_at').defaultNow().notNull(),
updatedAt: timestamp('updated_at').defaultNow().notNull()
updatedAt: timestamp('updated_at').defaultNow().notNull(),
}, t => ({
pk: primaryKey({columns: [t.id, t.email]})
pk: primaryKey({ columns: [t.id, t.email] }),
}))
export const guestbookMessages = pgTable('guestbook_messages', {
@@ -43,7 +43,7 @@ export const guestbookMessages = pgTable('guestbook_messages', {
email: text('email').notNull().unique(),
username: text('username').notNull(),
image: text('image').notNull(),
createdAt: timestamp('created_at').defaultNow().notNull()
createdAt: timestamp('created_at').defaultNow().notNull(),
})
export const categoriesType = pgEnum('categoryType', ['talent', 'bookmark'])
@@ -53,7 +53,7 @@ export const categories = pgTable('categories', {
slug: text('slug').unique().notNull(),
name: text('name').notNull(),
type: categoriesType('type').notNull(),
createdAt: timestamp('created_at').defaultNow().notNull()
createdAt: timestamp('created_at').defaultNow().notNull(),
})
export const talents = pgTable('talents', {
@@ -63,14 +63,14 @@ export const talents = pgTable('talents', {
website: text('website').default('').notNull(),
work: text('work').default('').notNull(),
favorite: boolean('favorite').default(false).notNull(),
createdAt: timestamp('created_at').defaultNow().notNull()
createdAt: timestamp('created_at').defaultNow().notNull(),
})
export const talentsToCategories = pgTable('talents_categories', {
talentId: integer('talent_id').notNull()
.references(() => talents.id, { onDelete: 'cascade' }),
categoryId: integer('category_id').notNull()
.references(() => categories.id, {onDelete: 'cascade'})
.references(() => categories.id, { onDelete: 'cascade' }),
})
export const bookmarks = pgTable('bookmarks', {
@@ -78,51 +78,51 @@ export const bookmarks = pgTable('bookmarks', {
name: text('name').notNull(),
website: text('website').default('').notNull(),
favorite: boolean('favorite').default(false).notNull(),
createdAt: timestamp('created_at').defaultNow().notNull()
createdAt: timestamp('created_at').defaultNow().notNull(),
})
export const bookmarksToCategories = pgTable('bookmarks_categories', {
bookmarkId: integer('bookmark_id').notNull()
.references(() => bookmarks.id, { onDelete: 'cascade' }),
categoryId: integer('category_id').notNull()
.references(() => categories.id, {onDelete: 'cascade'})
.references(() => categories.id, { onDelete: 'cascade' }),
}, t => ({
pk: primaryKey({columns: [t.bookmarkId, t.categoryId]})
pk: primaryKey({ columns: [t.bookmarkId, t.categoryId] }),
}))
// R E L A T I O N S
export const talentsRelations = relations(talents, ({ many }) => ({
talentCategories: many(talentsToCategories)
talentCategories: many(talentsToCategories),
}))
export const bookmarksRelations = relations(bookmarks, ({ many }) => ({
bookmarkCategories: many(bookmarksToCategories)
bookmarkCategories: many(bookmarksToCategories),
}))
export const categoriesRelations = relations(categories, ({ many }) => ({
talentsToCategories: many(talentsToCategories),
bookmarksToCategories: many(bookmarksToCategories)
bookmarksToCategories: many(bookmarksToCategories),
}))
export const talentsToCategoriesRelations = relations(talentsToCategories, ({ one }) => ({
talent: one(talents, {
references: [talents.id],
fields: [talentsToCategories.talentId]
fields: [talentsToCategories.talentId],
}),
category: one(categories, {
references: [categories.id],
fields: [talentsToCategories.categoryId]
})
fields: [talentsToCategories.categoryId],
}),
}))
export const bookmarksToCategoriesRelations = relations(bookmarksToCategories, ({ one }) => ({
bookmark: one(bookmarks, {
references: [bookmarks.id],
fields: [bookmarksToCategories.bookmarkId]
fields: [bookmarksToCategories.bookmarkId],
}),
category: one(categories, {
references: [categories.id],
fields: [bookmarksToCategories.categoryId]
})
fields: [bookmarksToCategories.categoryId],
}),
}))