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
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?3 Replies
I've also tried just pushing the binary as-is into a string
but it's then complaining about the length (even though signKeyMessyString.length = 32).
Could you please create a GH issue for that. Would help us to track it properly
Okay so I finally figured this out, turns out the string type is correct as MYSQL accepts hex strings as input to a binary row. This might not be the most efficient way of handling this but it does seem to work