ethan!
ethan!
Explore posts from servers
DTDrizzle Team
Created by ethan! on 5/27/2024 in #help
Enums
const validStatuses = ["claimed", "confirmed", "started"] as const;
const statusEnum = pgEnum("status", validStatuses);
export type SessionStatus = typeof validStatuses[number];

export const trainingsTable = pgTable("training", {
date: text("date").primaryKey(),
host: text("host").notNull(),
status: statusEnum("status").notNull(),
notificationID: text("notification_id"),
notificationDeletionDate: timestamp("notification_deletion_date")
});
const validStatuses = ["claimed", "confirmed", "started"] as const;
const statusEnum = pgEnum("status", validStatuses);
export type SessionStatus = typeof validStatuses[number];

export const trainingsTable = pgTable("training", {
date: text("date").primaryKey(),
host: text("host").notNull(),
status: statusEnum("status").notNull(),
notificationID: text("notification_id"),
notificationDeletionDate: timestamp("notification_deletion_date")
});
When I run drizzle-kit push --config=src/db/config.ts it returns error: type "status" does not exist, how do I fix this?
9 replies
DTDrizzle Team
Created by ethan! on 5/9/2024 in #help
CUUID
is there functionality for cuuid instead of just uuid?
1 replies
DTDrizzle Team
Created by ethan! on 4/28/2024 in #help
Issue with JSON + TypScript
Here's my code:
.findFirst({ where: eq(globalBans.offender.id, userID) });
.findFirst({ where: eq(globalBans.offender.id, userID) });
Here's my schema:
interface GlobalBanUser {
id: string;
username: string;
avatar: string;
};

export const globalBans = pgTable("global_bans", {
offender: json("offender").notNull().$type<GlobalBanUser>(),
reason: text("reason").notNull(),
evidence: json("evidence").notNull().$type<string[]>(),
moderator: json("moderator").notNull().$type<GlobalBanUser>(),
notes: text("notes").notNull(),
date: timestamp("date", { mode: "date" }).defaultNow()
});
interface GlobalBanUser {
id: string;
username: string;
avatar: string;
};

export const globalBans = pgTable("global_bans", {
offender: json("offender").notNull().$type<GlobalBanUser>(),
reason: text("reason").notNull(),
evidence: json("evidence").notNull().$type<string[]>(),
moderator: json("moderator").notNull().$type<GlobalBanUser>(),
notes: text("notes").notNull(),
date: timestamp("date", { mode: "date" }).defaultNow()
});
Here's my error:
Property 'id' does not exist on type 'PgColumn<{ name: "offender"; tableName: "global_bans"; dataType: "json"; columnType: "PgJson"; data: GlobalBanUser; driverParam: unknown; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, {}, {}>'.
Property 'id' does not exist on type 'PgColumn<{ name: "offender"; tableName: "global_bans"; dataType: "json"; columnType: "PgJson"; data: GlobalBanUser; driverParam: unknown; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, {}, {}>'.
2 replies