bind/js: Partially implements pragma

Some pragmas may return more than one value, which would
break the current logic. So this cause should be handled in the future
This commit is contained in:
Diego Reis 2025-05-25 15:56:28 -03:00
parent 1ff454853b
commit 60b78b3566
4 changed files with 70 additions and 9 deletions

View file

@ -77,13 +77,19 @@ class Database {
pragma(source, options) {
if (options == null) options = {};
if (typeof source !== "string")
throw new TypeError("Expected first argument to be a string");
if (typeof options !== "object")
throw new TypeError("Expected second argument to be an options object");
const simple = options["simple"];
const stmt = this.prepare(`PRAGMA ${source}`, this, true);
return simple ? stmt.pluck().get() : stmt.all();
const pragma = `PRAGMA ${source}`;
return simple
? this.db.pragma(pragma, true)
: this.db.pragma(pragma, false);
}
backup(filename, options) {