question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Option to convert query rows snake_case fields to camelCase

See original GitHub issue

Is it possible for node-postgres to have a configuration option to convert snake_case database fields into camelCase automagically for the result.rows when a successful query is returned?

I understand I could write a function to loop and pass it through myself, but I feel like that would be a double-up / extra process work. As the query already builds the rows, why not have the option of camelCase conversion too rather than query building the rows, then having to re-build them myself.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
hoegaardencommented, Jun 2, 2014

If there is anybody interessted: https://www.npmjs.org/package/pg-camelcase

2reactions
hoegaardencommented, Jan 24, 2014

I don’t think such a thing should be in in node-postgres. I wouldn’t want my client to change data in such a way.

This being said, I think you have (amongs others) following possibilities:

HTH

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Most efficient way of transforming query result ...
Both approaches are fine. You can do it either in SQL: const {rows} = await db.query( `SELECT first_name AS "firstName", middle_name AS ...
Read more >
Snake case to camel case conversion | Objection.js
When the conversion is done on knex level everything is converted to camel case including properties and identifiers in relationMappings and queries.
Read more >
Converting snake_case and camelCase between SQL and ...
One approach that addresses this, is manually renaming in your SQL queries using AS clause. For example, when querying the database you could ......
Read more >
Deserialize Snake Case to Camel Case With Jackson
In this article, we've seen different ways to deserialize snake case JSON to camel case fields using Jackson.
Read more >
postgresql - Should I not use camelCase in my column names?
lodash has snakeCase and camelCase functions that should come in handy. ... in camel case (and constantly be wrapping your SQL query column ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found