3 ms·
Use --tuples-only / -t and --no-align / -A. Or -tA for short. For example: $ psql dbname -tAc 'SELECT json_agg(some_table) FROM some_table' That will produ
by bagol 7y ago
Use --tuples-only / -t and --no-align / -A. Or -tA for short.
For example:
$ psql dbname -tAc 'SELECT json_agg(some_table) FROM some_table'
That will produce a valid JSON if you ever need to pipe it to another command. And I'm sure, psql will do the job a lot faster than node.
By the way, you should not underestimate the built-in psql power and postgresql's json capability. Postgresql's JSON power rivals that of other JSON based No-SQL databases.