mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-27 20:41:58 +03:00
Add a demonstration sqlite3_vtab/module implemented in JS, based on ext/misc/templatevtab.c. Add oo1.selectArrays() and selectObjects().
FossilOrigin-Name: 60482c97e02bc4cafefef281be0cf0bc8c5c53232162829c137f3f7a80cdc534
This commit is contained in:
@ -473,6 +473,15 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
return rc;
|
||||
};
|
||||
|
||||
/**
|
||||
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
|
||||
@ -1098,6 +1107,26 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
return __selectFirstRow(this, sql, bind, {});
|
||||
},
|
||||
|
||||
/**
|
||||
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.
|
||||
|
Reference in New Issue
Block a user