Data Retrieved As Same Data

I am retrieving some data using an api, and I'm only getting the same number in one column even though the data is different in the database. My database has a column that is default uuid_short(), is this the correct way to do the schema?
export const auditsTable = mysqlTable("audits", {
AUDIT_ID: varchar("AUDIT_ID", { length: 255 })
.primaryKey()
.$default(() => sql`(uuid_short())`),
DATE: date("DATE").notNull(),
user: varchar("user", { length: 255 }).notNull(),
upc: varchar("upc", { length: 255 }).notNull(),
epc: varchar("epc", { length: 255 }).notNull(),
ex_upc: varchar("ex_upc", { length: 255 }).notNull(),
status: tinyint("status").notNull(),
});
export const auditsTable = mysqlTable("audits", {
AUDIT_ID: varchar("AUDIT_ID", { length: 255 })
.primaryKey()
.$default(() => sql`(uuid_short())`),
DATE: date("DATE").notNull(),
user: varchar("user", { length: 255 }).notNull(),
upc: varchar("upc", { length: 255 }).notNull(),
epc: varchar("epc", { length: 255 }).notNull(),
ex_upc: varchar("ex_upc", { length: 255 }).notNull(),
status: tinyint("status").notNull(),
});
1 Reply
rphlmr ⚡
rphlmr ⚡5mo ago
Maybe AUDIT_ID should have
.default(sql`uuid_short()`)
.default(sql`uuid_short()`)
And not $default that is executed at runtime by javascript but not by the db. I am not sure but despite that the schema looks good.
Want results from more Discord servers?
Add your server