From 7924dfe47bf7ba3552d18f8187b3d31ef143c6be Mon Sep 17 00:00:00 2001 From: tpoisseau <22891227+tpoisseau@users.noreply.github.com> Date: Thu, 21 Nov 2024 09:56:04 +0100 Subject: [PATCH 1/2] sqlite: add `StatementSync.prototype.iterate` method --- doc/api/sqlite.md | 19 +++ src/env_properties.h | 6 + src/node_sqlite.cc | 176 ++++++++++++++++++++ src/node_sqlite.h | 6 + test/parallel/test-sqlite-statement-sync.js | 28 ++++ 5 files changed, 235 insertions(+) diff --git a/doc/api/sqlite.md b/doc/api/sqlite.md index 048ba67eeac7f7..4e27d0d8bc5f26 100644 --- a/doc/api/sqlite.md +++ b/doc/api/sqlite.md @@ -287,6 +287,25 @@ object. If the prepared statement does not return any results, this method returns `undefined`. The prepared statement [parameters are bound][] using the values in `namedParameters` and `anonymousParameters`. +### `statement.iterate([namedParameters][, ...anonymousParameters])` + + + +* `namedParameters` {Object} An optional object used to bind named parameters. + The keys of this object are used to configure the mapping. +* `...anonymousParameters` {null|number|bigint|string|Buffer|Uint8Array} Zero or + more values to bind to anonymous parameters. +* Returns: {Iterator} An iterable iterator of objects. Each object corresponds to a row + returned by executing the prepared statement. The keys and values of each + object correspond to the column names and values of the row. + +This method executes a prepared statement and returns an iterator of +objects. If the prepared statement does not return any results, this method +returns an empty iterator. The prepared statement [parameters are bound][] using +the values in `namedParameters` and `anonymousParameters`. + ### `statement.run([namedParameters][, ...anonymousParameters])`