Transform Postgres array into JS array

Dddanielcruzz5/8/2023
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 queries
UUUnknown User5/8/2023
2 Messages Not Public
Sign In & Join Server To View
Dddanielcruzz5/8/2023
I'm getting a string. Maybe is the fact that my column type is an enum array?
UUUnknown User5/8/2023
Message Not Public
Sign In & Join Server To View
Dddanielcruzz5/8/2023
UUUnknown User5/8/2023
3 Messages Not Public
Sign In & Join Server To View
Dddanielcruzz5/8/2023
do you know how can I define the custom types with Kysely? ๐Ÿ˜…
UUUnknown User5/8/2023
6 Messages Not Public
Sign In & Join Server To View
Dddanielcruzz5/8/2023
Yep, I ended up doing

...
.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
Kkoskimas5/9/2023
As using oid seems brittle, for any reason the id could change between dev and prod
You mean the data type oid in setTypeParser?
Kkoskimas5/9/2023
It won't change Actually with custom types, I'm not so sure
Dddanielcruzz5/10/2023
Yeah, the custom type oid was different in my local db and prod db, idk why ๐Ÿคทโ€โ™‚๏ธ but better not to risk it
IIgal5/12/2023
This can be more type-safe:

.select((eb) => sql<string[]>`${eb.ref('categories')}::text[]`.as('categories'))
Dddanielcruzz5/18/2023
You're the best