export const user = pgTable('user', {
id: serial('id').primaryKey(),
username: text('username').notNull(),
email: text('email').notNull(),
password: text('password').notNull(),
bio: text('bio').default(null),
image: text('image').default(null),
});
export const userRelations = relations(user, ({ many }) => ({
article: many(article),
}));
export const article = pgTable('article', {
id: serial('id').primaryKey(),
slug: text('slug').notNull(),
title: text('title').notNull(),
description: text('description').default(null),
body: text('body').default(null),
createdAt: timestamp('createdAt').defaultNow(),
updatedAt: timestamp('updatedAt'),
tagList: text('tagList').notNull().array(),
favoritesCount: integer('favoritesCount').default(0),
authorId: integer('authorId').references(() => user.id),
});
export const articleRelations = relations(article, ({ one }) => ({
authorId: one(user, {
fields: [article.authorId],
references: [user.id],
}),
}));
export const user = pgTable('user', {
id: serial('id').primaryKey(),
username: text('username').notNull(),
email: text('email').notNull(),
password: text('password').notNull(),
bio: text('bio').default(null),
image: text('image').default(null),
});
export const userRelations = relations(user, ({ many }) => ({
article: many(article),
}));
export const article = pgTable('article', {
id: serial('id').primaryKey(),
slug: text('slug').notNull(),
title: text('title').notNull(),
description: text('description').default(null),
body: text('body').default(null),
createdAt: timestamp('createdAt').defaultNow(),
updatedAt: timestamp('updatedAt'),
tagList: text('tagList').notNull().array(),
favoritesCount: integer('favoritesCount').default(0),
authorId: integer('authorId').references(() => user.id),
});
export const articleRelations = relations(article, ({ one }) => ({
authorId: one(user, {
fields: [article.authorId],
references: [user.id],
}),
}));