noah
noah
Aarktype
Created by noah on 4/6/2025 in #questions
Generic wrapper for drizzle-arktype functions
yeah even when filling out all the attributes it does not work. Would it not make sense to just always emit an object type? After all its a datatable it will always be an object
8 replies
Aarktype
Created by noah on 4/6/2025 in #questions
Generic wrapper for drizzle-arktype functions
@Mario564 sorry for the ping but would you mind looking at this one more time id really appreciate it
8 replies
Aarktype
Created by noah on 4/6/2025 in #questions
Generic wrapper for drizzle-arktype functions
I don't know if I am being stupid but I dont think that PgIntegerColumn etc. exist. Also the PgTableWithColumns type takes a bunch of other arguments like name, dialect etc. The suggested code above did not work for me. I now tried the following. Manually providing the types like so:
export function insertSchema<T extends PgTableWithColumns<{
name: "",
dialect: "pg",
schema: undefined,
columns: {
id: PgIntegerBuilderInitial<"id">,
}
}>(table: T) {
return createInsertSchema(table)
.omit('id', 'createdAt', 'updatedAt')
.onUndeclaredKey('delete')
}
export function insertSchema<T extends PgTableWithColumns<{
name: "",
dialect: "pg",
schema: undefined,
columns: {
id: PgIntegerBuilderInitial<"id">,
}
}>(table: T) {
return createInsertSchema(table)
.omit('id', 'createdAt', 'updatedAt')
.onUndeclaredKey('delete')
}
Or just taking the type of a real table like so:
const testTable = pgTable('test', (t) => ({
...WITH_ID,
...WITH_TIMESTAMPS,
}))

export function insertSchema<T extends typeof testTable>(table: T) {
return createInsertSchema(table)
.omit('id', 'createdAt', 'updatedAt')
.onUndeclaredKey('delete')
}
const testTable = pgTable('test', (t) => ({
...WITH_ID,
...WITH_TIMESTAMPS,
}))

export function insertSchema<T extends typeof testTable>(table: T) {
return createInsertSchema(table)
.omit('id', 'createdAt', 'updatedAt')
.onUndeclaredKey('delete')
}
Neither of these worked for me
8 replies