Node-postgres: SQL select statement result rows and anonymous

Created on 16 Sep 2016  路  2Comments  路  Source: brianc/node-postgres

I've noticed that the result rows object array are wrapped in anonymous for each entry. Here is an example below. It doesnt matter if its a select, insert, etc.

{ command: 'SELECT',
rowCount: 3,
oid: NaN,
rows:
[ anonymous {
session_id: '59',
token: 'e0a9b5ac-4ea3-4d8f-bcd8-a44babdfcc38',
account_id: '1',
date_created: '2016-09-16T19:34:40Z',
date_modified: '2016-09-16T19:34:40Z',
date_expired: null },
anonymous {
session_id: '58',
token: 'e50df143-f9d9-46d8-979a-d9f4c68af5b8',
account_id: '1',
date_created: '2016-09-16T18:41:56Z',
date_modified: '2016-09-16T18:41:56Z',
date_expired: null },
anonymous {
session_id: '57',
token: 'ac4a923e-32c5-45d1-9a3b-c73c12142d76',
account_id: '1',
date_created: '2016-09-16T18:41:20Z',
date_modified: '2016-09-16T18:41:20Z',
date_expired: null } ],
fields: .....

I was wondering if there was a way to have the results without the "anonymous", like:

{ command: 'SELECT',
rowCount: 3,
oid: NaN,
rows:
[ {
session_id: '59',
token: 'e0a9b5ac-4ea3-4d8f-bcd8-a44babdfcc38',
account_id: '1',
date_created: '2016-09-16T19:34:40Z',
date_modified: '2016-09-16T19:34:40Z',
date_expired: null
},
{
session_id: '58',
token: 'e50df143-f9d9-46d8-979a-d9f4c68af5b8',
account_id: '1',
date_created: '2016-09-16T18:41:56Z',
date_modified: '2016-09-16T18:41:56Z',
date_expired: null
},
{
session_id: '57',
token: 'ac4a923e-32c5-45d1-9a3b-c73c12142d76',
account_id: '1',
date_created: '2016-09-16T18:41:20Z',
date_modified: '2016-09-16T18:41:20Z',
date_expired: null
} ],
fields: .....

Thanks

Most helpful comment

You might be able to override the way v8 does console.log on object types to get rid of that - otherwise I don't think it's removable. It has to do w/ a substantial perf improvment internal to node postgres to use anonymous classes versus plain JavaScript hashes when building up results-sets.

All 2 comments

You might be able to override the way v8 does console.log on object types to get rid of that - otherwise I don't think it's removable. It has to do w/ a substantial perf improvment internal to node postgres to use anonymous classes versus plain JavaScript hashes when building up results-sets.

Your right, I thought it was the response from the query. Thanks for clearing it up for me

Was this page helpful?
0 / 5 - 0 ratings