@sqb/sqljs
Version:
SQB serialization extension for sql.js driver
33 lines (32 loc) • 796 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SqljsCursor = void 0;
class SqljsCursor {
constructor(stmt, opts) {
this._rowType = opts.rowType;
this._stmt = stmt;
}
get isClosed() {
return !this._stmt;
}
get rowType() {
return this._rowType;
}
async close() {
if (!this._stmt)
return;
this._stmt.free();
this._stmt = undefined;
}
async fetch(nRows) {
if (!this._stmt)
return;
const stmt = this._stmt;
const rows = [];
while (nRows-- && stmt.step()) {
rows.push(this.rowType === 'object' ? stmt.getAsObject() : stmt.get());
}
return rows;
}
}
exports.SqljsCursor = SqljsCursor;