Skip to content

node:sqlite to support retrieving rows as arrays instead of objects #57534

@WillAvudim

Description

@WillAvudim

What is the problem this feature will solve?

Currently node:sqlite Session.* methods retrieve rows only as objects. In the application we write columns are auto-generated, their names are inherently meaningless, and their retrieval as an object would result in node_sqlite wasting CPU cycles to construct the object, and then I would have to run through reverse lookup loop over the keys of that unnecessarily constructed object to reproduce the original array of values as specified in the SELECT <expression1>, <expression2>, ... <expressionN> sequence.

In other words,

  1. I'll have to encode it as
    SELECT <expression1> AS c0, <expression2> AS c1, ... <expressionN> AS cN
  2. node:sqlite would have to construct and return an object { c0: <val>, c1: <val>, ..., cN: <val>}
  3. And then I'll have to reconstruct the array by interating over the object keys [c0, c1, ..., cN] to arrive at [val0, val1, ..., valN].

I'd like to request support of array row retrieval, just like it's already supported by all other sqlite APIs (like better-sqlite3, native WASM sqlite api-oo1, etc).
Object retrieval is unnecessary wasteful and impractical, especially when the number of retrieved columns (expressions) is measured in hundreds and their names are inherently meaningless.

What is the feature you are proposing to solve the problem?

Either add a parameter to request an array per row instead of object per row, or add additional methods that achieve this.
Other libraries tend to pass this in as a parameter.

What alternatives have you considered?

better-sqlite3, sqlite WASM api-oo1, even python libraries support this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.sqliteIssues and PRs related to the SQLite subsystem.

    Type

    No type

    Projects

    Status

    Triaged

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions