rmtm
rmtm
DTDrizzle Team
Created by rmtm on 8/16/2023 in #help
Binary typing for Mysql & typescript
hey hopefully quick question, I have a mysql column of type binary(32), but the type coertion seems to only be accepting strings
// type definition
signingKey: binary('signing_key', { length: 32 })

// in use, typescript gives an error:
tx.insert(auth).values({signingKey:signKeyBytes})
// type definition
signingKey: binary('signing_key', { length: 32 })

// in use, typescript gives an error:
tx.insert(auth).values({signingKey:signKeyBytes})
It won't accept signKeyBytes as Uint8Array which is what I'd expect. I suppose I could just use a longer string column but I'd prefer to use the binary as that's how I need it on the server end and I'd like to avoid the base64 encode/decode step each time. This is what the type error says is the accepted type for signingKey: string | SQL<unknown> | Placeholder<string, any> | null | undefined. Any idea how I could do this cleanly?
4 replies