Skip to content
Discussion options

You must be logged in to vote

That is because results are by default an array of row "objects". That means if there are duplicate names for a column, the last one wins.

You can indeed have results returned as an array of row "arrays", instead as your mention, but yes - not very ergonomic.

Also when working with Postgres.js it helps a lot to embrace the PostgreSQL json functions. Most used are row_to_json, json_agg and eg. json_build_object.

If you are in control of the schema I would also highly recommend going with a table prefixed primary key. There are so many benefits, which you can probably find plenty of discussions around elsewhere too, but look at how your example could be instead:

create table cars (
  car_id

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@KeyboardRage
Comment options

Answer selected by KeyboardRage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants