added remaining user api

This commit is contained in:
2024-04-19 15:05:01 +07:00
parent a3f61b35c1
commit e0ec4c2b49
7 changed files with 83 additions and 443 deletions

View File

@@ -41,7 +41,7 @@ export const userRelation = relations(user, ({ many, one }) => ({
//----------------Group
export const group = sqliteTable("groups", {
id: integer("id", { mode: "number" }).primaryKey({ autoIncrement: true }),
name: text("name"),
name: text("name").notNull(),
});
export const groupRelation = relations(group, ({ many }) => ({
@@ -51,19 +51,25 @@ export const groupRelation = relations(group, ({ many }) => ({
//----------------Opinion
export const opinion = sqliteTable("opinions", {
id: integer("id", { mode: "number" }).primaryKey({ autoIncrement: true }),
name: text("name"),
type: text("type", { enum: ["3Choice", "4Choice"] }),
name: text("name").notNull(),
type: text("type", { enum: ["3Choice", "4Choice"] })
.default("3Choice")
.notNull(),
});
//----------------UserOpinion
export const userOpinion = sqliteTable(
"user_opinions",
{
userId: integer("user_id").references(() => user.id),
opinionId: integer("opinion_id").references(() => opinion.id),
userId: integer("user_id")
.notNull()
.references(() => user.id),
opinionId: integer("opinion_id")
.notNull()
.references(() => opinion.id),
choice: text("choice", {
enum: ["agree", "disagree", "deciding", "ignore"],
}).default("ignore"),
}).default("deciding"),
},
(t) => ({
pk: primaryKey({ columns: [t.userId, t.opinionId] }),