Skip to content

What is the correct syntax for including SQL values AND rowsAsArray option in a query? #3130

@millerbryan

Description

@millerbryan

Discussed in #3095

This is really a documentation enhancement request and should not be moved to a discussion.

There is no place in the docs where the correct syntax for using both rowsAsArray and a SQL value is shown.

Originally posted by millerbryan October 2, 2024
I've looked at all the examples in the docs which use rowsAsArray and it isn't clear how to specify it in a query (rather than in the connection) when passing in SQL values. Is this possible to pass both?

// simplified code
const sql = "select county_name from static_web_data.state_counties where state_name = ?";
const state = "TX"

        try {
          const [rows, fields] = await pool.query({sql, [state], rowsAsArray: true});
          if (rows) {
            return rows;
          }
        } catch (err) {
          console.log(err);
        }
```</div>

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions