denodrivers / postgres

PostgreSQL driver for Deno

Home Page:https://denodrivers.github.io/postgres

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option to automatically turn snake_case columns in a query response into camelCase fields

lucacasonato opened this issue · comments

deno lint mandates camelCase for objects because this fits more naturally into the language and platform standard library (eg Response.bodyUsed, not Response.body_used). Most sql tables however use camel_case for naming.

Usage example:

CREATE TABLE users (
  id SERIAL PRIMARY KEY,
  user_name TEXT NOT NULL
);
INSERT INTO users (user_name) VALUES ('lucacasonato');
const { rows } = await db.queryObject`SELECT * FROM users`;
console.log(rows); // [ { id: 1, userName: "lucacasonato" } ]

I think this could be an option on the connection itself.

#343 new pull request to close this issue

@Soremwar please don't forget to close this issue.

Best