added remaining user api
This commit is contained in:
@@ -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] }),
|
||||
|
||||
Reference in New Issue
Block a user