File tree Expand file tree Collapse file tree 2 files changed +30
-7
lines changed
Expand file tree Collapse file tree 2 files changed +30
-7
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,26 @@ RocksDatabase.config({
9191});
9292```
9393
94+ ### ` db.isOpen(): boolean `
95+
96+ Returns ` true ` if the database is open, otherwise false.
97+
98+ ``` typescript
99+ console .log (db .isOpen ()); // true or false
100+ ```
101+
102+ ### ` db.name: string `
103+
104+ Returns the database column family's name.
105+
106+ ``` typescript
107+ const db = new RocksDatabase (' path/to/db' );
108+ console .log (db .name ); // 'default'
109+
110+ const db2 = new RocksDatabase (' path/to/db' , { name: ' users' });
111+ console .log (db .name ); // 'users'
112+ ```
113+
94114### ` db.open(): RocksDatabase `
95115
96116Opens the database at the given path. This must be called before performing any data operations.
@@ -108,16 +128,12 @@ There's also a static `open()` method for convenience that performs the same thi
108128const db = RocksDatabase .open (' path/to/db' );
109129```
110130
111- ### ` db.name: string `
131+ ### ` db.status: 'opened' | 'closed' `
112132
113- Returns the database column family's name .
133+ Returns a string ` 'opened' ` or ` 'closed' ` indicating if the database is opened or closed .
114134
115135``` typescript
116- const db = new RocksDatabase (' path/to/db' );
117- console .log (db .name ); // 'default'
118-
119- const db2 = new RocksDatabase (' path/to/db' , { name: ' users' });
120- console .log (db .name ); // 'users'
136+ console .log (db .status );
121137```
122138
123139## Data Operations
Original file line number Diff line number Diff line change @@ -443,6 +443,13 @@ export class RocksDatabase extends DBI<DBITransactional> {
443443 return this . store . db . purgeLogs ( options ) ;
444444 }
445445
446+ /**
447+ * The status of the database.
448+ */
449+ get status ( ) : 'open' | 'closed' {
450+ return this . store . isOpen ( ) ? 'open' : 'closed' ;
451+ }
452+
446453 /**
447454 * Executes all operations in the callback as a single transaction.
448455 *
You can’t perform that action at this time.
0 commit comments