K
Join ServerKysely
help
Transform Postgres array into JS array
Hey, I was wondering if there's a helper or something to transform Postgres arrays
{one, two}
into JS arrays ['one', 'two']
. Right I know the Postgres array is turned into a string when executing queries2 Messages Not Public
Sign In & Join Server To View
I'm getting a string. Maybe is the fact that my column type is an enum array?
Message Not Public
Sign In & Join Server To View
3 Messages Not Public
Sign In & Join Server To View
Seems I have to add a parser https://github.com/brianc/node-pg-types/issues/56#issuecomment-323223477
do you know how can I define the custom types with Kysely? ๐
6 Messages Not Public
Sign In & Join Server To View
Yep, I ended up doing
As using oid seems brittle, for any reason the id could change between dev and prod
...
.selectAll("Collection")
.select((eb) => [
sql<string[]>`categories::text[]`.as("categories"),
...
As using oid seems brittle, for any reason the id could change between dev and prod
As using oid seems brittle, for any reason the id could change between dev and prodYou mean the data type oid in
setTypeParser
?Yeah, the custom type oid was different in my local db and prod db, idk why ๐คทโโ๏ธ but better not to risk it
This can be more type-safe:
.select((eb) => sql<string[]>`${eb.ref('categories')}::text[]`.as('categories'))
You're the best