diff options
author | stephan <stephan@noemail.net> | 2022-09-30 15:46:08 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-09-30 15:46:08 +0000 |
commit | 07c0b722530b67cf9c56129da386e809efa5bdc2 (patch) | |
tree | 47e426174278cfc2e4b93568cffe16907c33ed1c /ext/wasm/api/sqlite3-api-oo1.js | |
parent | 359d62395ec5423b5ac906dd9fda300d679d34b7 (diff) | |
download | sqlite-07c0b722530b67cf9c56129da386e809efa5bdc2.tar.gz sqlite-07c0b722530b67cf9c56129da386e809efa5bdc2.zip |
Add oo1.JsStorageDb.clearStorage/storageSize() methods, copies of capi.sqlite3_web_kvvfs_clear/size().
FossilOrigin-Name: 1e09efe7fa15b8908f8b8353164a8361de778e27ea6c0b11c402bf4e1c56333d
Diffstat (limited to 'ext/wasm/api/sqlite3-api-oo1.js')
-rw-r--r-- | ext/wasm/api/sqlite3-api-oo1.js | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js index 1daf6eb00..19e9e61f0 100644 --- a/ext/wasm/api/sqlite3-api-oo1.js +++ b/ext/wasm/api/sqlite3-api-oo1.js @@ -426,6 +426,14 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ DB.checkRc = checkSqlite3Rc; DB.prototype = { + /** Returns true if this db handle is open, else false. */ + isOpen: function(){ + return !!this.pointer; + }, + /** Throws if this given DB has been closed, else returns `this`. */ + affirmOpen: function(){ + return affirmDbOpen(this); + }, /** Finalizes all open statements and closes this database connection. This is a no-op if the db has already been @@ -1666,8 +1674,28 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ vfs: "kvvfs" }); }; - sqlite3.oo1.JsStorageDb.prototype = Object.create(DB.prototype); - } + const jdb = sqlite3.oo1.JsStorageDb; + jdb.prototype = Object.create(DB.prototype); + /** Equivalent to sqlite3_web_kvvfs_clear(). */ + jdb.clearStorage = capi.sqlite3_web_kvvfs_clear; + /** + Clears this database instance's storage or throws if this + instance has been closed. Returns the number of + database blocks which were cleaned up. + */ + jdb.prototype.clearStorage = function(){ + return jdb.clearStorage(affirmDbOpen(this).filename); + }; + /** Equivalent to sqlite3_web_kvvfs_size(). */ + jdb.storageSize = capi.sqlite3_web_kvvfs_size; + /** + Returns the _approximate_ number of bytes this database takes + up in its storage or throws if this instance has been closed. + */ + jdb.prototype.storageSize = function(){ + return jdb.storageSize(affirmDbOpen(this).filename); + }; + }/*main-window-only bits*/ }); |