Skip to content

Request for firstRow/allRows convenience methods #1534

Closed
@aloisbarreras

Description

@aloisbarreras

When executing queries with this library like so:
db.query('select * from users').then(res => res.rows[0]);

I very often just want to get the first row from the result, and it's tedious to retype the .then(res => res.rows[0]) every time.

It would be great to add some convenience methods like firstRow() or allRows() that would save a lot of typing. For example:

db.query('select * from users').firstRow()
db.query('select * from users').allRows()
db.query('select * from users')

Omitting the methods would maintain the current functionality.

Let me know if you think this is a worthwhile addition.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions