aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-api-oo1.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/wasm/api/sqlite3-api-oo1.js')
-rw-r--r--ext/wasm/api/sqlite3-api-oo1.js43
1 files changed, 36 insertions, 7 deletions
diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js
index e077b0c50..6253c659f 100644
--- a/ext/wasm/api/sqlite3-api-oo1.js
+++ b/ext/wasm/api/sqlite3-api-oo1.js
@@ -192,13 +192,13 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
/**
Sets SQL which should be exec()'d on a DB instance after it is
opened with the given VFS pointer. The SQL may be any type
- supported by the "flexible-string" function argument
- conversion. Alternately, the 2nd argument may be a function, in
- which case it is called with (theOo1DbObject,sqlite3Namespace) at
- the end of the DB() constructor. The function must throw on
- error, in which case the db is closed and the exception is
- propagated. This function is intended only for use by DB
- subclasses or sqlite3_vfs implementations.
+ supported by the "string:flexible" function argument conversion.
+ Alternately, the 2nd argument may be a function, in which case it
+ is called with (theOo1DbObject,sqlite3Namespace) at the end of
+ the DB() constructor. The function must throw on error, in which
+ case the db is closed and the exception is propagated. This
+ function is intended only for use by DB subclasses or sqlite3_vfs
+ implementations.
*/
dbCtorHelper.setVfsPostOpenSql = function(pVfs, sql){
__vfsPostOpenSql[pVfs] = sql;
@@ -474,6 +474,15 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
};
/**
+ Internal impl of the DB.selectArrays() and
+ selectObjects() methods.
+ */
+ const __selectAll =
+ (db, sql, bind, rowMode)=>db.exec({
+ sql, bind, rowMode, returnValue: 'resultRows'
+ });
+
+ /**
Expects to be given a DB instance or an `sqlite3*` pointer (may
be null) and an sqlite3 API result code. If the result code is
not falsy, this function throws an SQLite3Error with an error
@@ -1099,6 +1108,26 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
},
/**
+ Runs the given SQL and returns an array of all results, with
+ each row represented as an array, as per the 'array' `rowMode`
+ option to `exec()`. An empty result set resolves
+ to an empty array. The second argument, if any, is treated as
+ the 'bind' option to a call to exec().
+ */
+ selectArrays: function(sql,bind){
+ return __selectAll(this, sql, bind, 'array');
+ },
+
+ /**
+ Works identically to selectArrays() except that each value
+ in the returned array is an object, as per the 'object' `rowMode`
+ option to `exec()`.
+ */
+ selectObjects: function(sql,bind){
+ return __selectAll(this, sql, bind, 'object');
+ },
+
+ /**
Returns the number of currently-opened Stmt handles for this db
handle, or 0 if this DB instance is closed.
*/