xdriver 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,108 +1,33 @@
1
- ## 文档懒得写,更详细API查看源码 目录:src/ts/
1
+ ## 说明
2
2
 
3
- ### indexDB
3
+ ### 初始化Connection
4
4
 
5
+ ```javascript
6
+ import {KeyRange, Driver} from 'xdriver';
7
+ // 初始化数据库驱动
8
+ const driver = new Driver('demo', version);
9
+ // 定义表结构以及初始化数据
10
+ driver.defineTables({
11
+ name: 'player',
12
+ primaryKey: 'id',
13
+ autoIncrement: true,
14
+ indexes: [
15
+ {name: 'age_index', column: 'age'},
16
+ {name: 'name_index', column: 'name'},
17
+ {name: 'double_index', column: ['sex', 'age']},
18
+ ],
19
+ rows: [{name: 'xxx', age: '', sex: ''}] //初始化数据
20
+ });
21
+ const connect = await driver.connect();
5
22
  ```
6
- import Driver from 'ndriver';
7
- const driver = new Driver('demo', version?);
8
- driver.on("process", function (state) {
9
- console.log(state)
10
- })
11
- driver.open().then(function () {
12
- var arrPlayers = []
13
- for(let i=0; i<100; i++) {
14
- arrPlayers.push({
15
- name: `韩梅梅${i}`,
16
- sex: `女${i}`
17
- })
18
- }
19
- driver.createTable({
20
- name: 'player',
21
- primaryKey: 'id',
22
- autoIncrement: true,
23
- indexes: [
24
- {name: 'name_index', column: 'name', unique: true},
25
- ],
26
- data : arrPlayers
27
- })
28
- })
29
- ```
30
-
31
- ### API
32
- #### constructor(name, version?)
33
- name: 数据库名字
34
- version: 数据库版本 默认1
35
- eg: var driver = new Driver('database')
36
- ### open
37
- 打开数据库连接 返回promise对象 在resolve中可以创建表或者删除表
38
- driver.open().then(() => {
39
- driver.createTable({
40
- name: 'table',
41
- primaryKey: 'key',
42
- indexes: [
43
- {name: 'name_index', column: 'key', unique: true},
44
- ],
45
- })
46
- })
47
- #### Driver.prototype.insert(table, data)
48
- table: 表名
49
- data: 需要插入的数据 obj or array
50
- eg: driver.insert({key: 'key', name: '', ...})
51
- #### Driver.prototype.select(table, keyRange?, limit?)
52
- table: 表名
53
- keyRange: KeyRange 包含多种比较操作
54
- limit: 取出记录数
55
- eg: driver.select('table', keyRange.eq('key'), 1).then(rs => console.log(rs))
56
-
57
- #### Driver.prototype.selectByKey(table, key)
58
- table:表名
59
- key: 主键
60
- eg: driver.selectByKey('key').then(rs => console.log(rs))
61
23
 
62
- #### Driver.prototype. count (table, keyRange?)
63
- 根据条件统计记录数
64
- table: 表名
65
- keyRange: @see select
66
- eg: driver.count('table').then(size => console.log(size))
67
- #### Driver.prototype. update (table, modify, where?)
68
- 数据更新,如果数据不存在则新增
69
- table: 表名
70
- modify: 修改的对象
71
- where:条件
72
- eg: driver.update('table', {name: 'xxxx'}, {key: 'key'})
73
- #### Driver.prototype.delete (table, key)
74
- table: 表名
75
- key: 主键
76
- 根据主键删除
77
- eg: driver.delete('table', 'key')
78
-
79
- #### Driver.prototype.truncate(table)
80
- 清空某张表
81
- table:表名
24
+ ### 操作表
82
25
 
83
- ### 示例
26
+ ```javascript
27
+ const player = connect.table('player');
84
28
 
85
- ```
86
- const driver = new Driver('pallet', 1);
87
- driver.on("process", function (state) {
88
- console.log(state)
89
- })
90
- driver.open().then(function () {
91
- var arrPlayers = []
92
- for(let i=0; i<100; i++) {
93
- arrPlayers.push({
94
- name: `韩梅梅${i}`,
95
- sex: `女${i}`
96
- })
97
- }
98
- driver.createTable({
99
- name: 'player',
100
- primaryKey: 'id',
101
- autoIncrement: true,
102
- indexes: [
103
- {name: 'name_index', column: 'name', unique: true},
104
- ],
105
- data : arrPlayers
106
- })
107
- })
29
+ let results = await player.queryByIndex('age_index', KeyRange.between(10, 20));
30
+ results = await player.queryByIndex('double_index', KeyRange.eq(['女3', 0]));
31
+ results = await player.query(KeyRange.between(10, 20))
32
+ results = connect.queryByIndex('tableName', 'indexName', KeyRange.between(10, 20))
108
33
  ```
package/lib/com.js CHANGED
@@ -17,13 +17,6 @@ export function _copy(src, target) {
17
17
  }
18
18
  return target;
19
19
  }
20
- var LogLevel;
21
- (function (LogLevel) {
22
- LogLevel[LogLevel["debug"] = 0] = "debug";
23
- LogLevel[LogLevel["warn"] = 1] = "warn";
24
- LogLevel[LogLevel["info"] = 2] = "info";
25
- LogLevel[LogLevel["error"] = 3] = "error";
26
- })(LogLevel || (LogLevel = {}));
27
20
  export class Logger {
28
21
  constructor(catalog) {
29
22
  this.catalog = catalog;
@@ -40,19 +33,19 @@ export class Logger {
40
33
  return `[${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}.${date.getMilliseconds()}]`;
41
34
  }
42
35
  debug(msg, ...args) {
43
- this.print(console.debug, `%c${this.getFormatDate()} [DEBUG] <${this.catalog}> ${msg}`, ...args, "color: gray;");
36
+ this.print(console.debug, `%c${this.getFormatDate()} [DEBUG] <${this.catalog}> ${msg}`, "color: gray;", ...args);
44
37
  }
45
38
  warn(msg, ...args) {
46
- this.print(console.warn, `%c${this.getFormatDate()} [WARN] <${this.catalog}> ${msg}`, ...args, "color: #FFCC00;");
39
+ this.print(console.warn, `%c${this.getFormatDate()} [WARN] <${this.catalog}> ${msg}`, "color: #FFCC00;", ...args);
47
40
  }
48
41
  info(msg, ...args) {
49
42
  this.print(console.info, `${this.getFormatDate()} [INFO] <${this.catalog}> ${msg}`, ...args);
50
43
  }
51
44
  error(msg, ...args) {
52
- this.print(console.error, `%c${this.getFormatDate()} [ERROR] <${this.catalog}> ${msg}`, ...args, "color: #EF4444;");
45
+ this.print(console.error, `%c${this.getFormatDate()} [ERROR] <${this.catalog}> ${msg}`, "color: #EF4444;", ...args);
53
46
  }
54
47
  success(msg, ...args) {
55
- this.print(console.log, `%c${this.getFormatDate()} [SUCCESS] <${this.catalog}> ${msg}`, ...args, "color: #10B981;");
48
+ this.print(console.log, `%c${this.getFormatDate()} [SUCCESS] <${this.catalog}> ${msg}`, "color: #10B981;", ...args);
56
49
  }
57
50
  static getLogger(catalog = 'default') {
58
51
  return new Logger(catalog);
@@ -0,0 +1,37 @@
1
+ import { IndexdbStatus } from "./const";
2
+ import Table, { ITable, TableMeta } from "./table";
3
+ interface EventMap {
4
+ process: (this: Connection, status: IndexdbStatus) => void;
5
+ success: (this: Connection, connect: IDBDatabase) => void;
6
+ blocked: (this: Connection, event: IDBVersionChangeEvent) => void;
7
+ change: (connect: IDBDatabase, event: IDBVersionChangeEvent) => void;
8
+ error: (evt: Event) => void;
9
+ close: () => void;
10
+ }
11
+ type EventKey = keyof EventMap;
12
+ export default class Connection {
13
+ name: string;
14
+ version: number;
15
+ idbDatabase?: IDBDatabase;
16
+ readonly tableMap: Map<string, Table>;
17
+ private eventMap;
18
+ constructor(database?: string, version?: number);
19
+ on<T extends EventKey>(event: T, handle: EventMap[T]): this;
20
+ get connected(): boolean;
21
+ connect(name?: string, version?: number, upgrade?: (idbDatabase: IDBDatabase, event: IDBVersionChangeEvent) => any): Promise<any>;
22
+ drop(): Promise<Event>;
23
+ close(): void;
24
+ createTable(tableName: string, meta?: Omit<TableMeta, 'name'> & {
25
+ overwrite?: boolean;
26
+ }, idbDatabase?: IDBDatabase): Promise<Table>;
27
+ createTables(tables: Array<string | (TableMeta & {
28
+ overwrite?: boolean;
29
+ })>, meta: (Omit<ITable, "name"> & {
30
+ overwrite?: boolean;
31
+ }) | undefined, idbDatabase: IDBDatabase): Promise<Table[]>;
32
+ dropTable(tableName: string): boolean;
33
+ table(tableName: string): Table;
34
+ exists(table: string): boolean;
35
+ getTables(): Table[];
36
+ }
37
+ export {};
@@ -0,0 +1,190 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { IndexdbStatus, innerDB } from "./const";
11
+ import Table from "./table";
12
+ import { Logger } from './com';
13
+ const logger = Logger.getLogger('Database');
14
+ export default class Connection {
15
+ constructor(database = 'default', version = 1) {
16
+ this.eventMap = {};
17
+ this.name = database;
18
+ this.version = version;
19
+ this.tableMap = new Map();
20
+ }
21
+ on(event, handle) {
22
+ this.eventMap[event] = handle;
23
+ return this;
24
+ }
25
+ get connected() {
26
+ return this.idbDatabase != void 0;
27
+ }
28
+ connect(name, version, upgrade) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ var _a;
31
+ if ((!name || version == void 0) && this.connected) {
32
+ return Promise.resolve(this);
33
+ }
34
+ this.name = name || this.name;
35
+ this.version = version || this.version;
36
+ logger.debug(`Connect to database ${this.name} ${this.version}`);
37
+ const request = innerDB.open(this.name, version);
38
+ (_a = this.eventMap.process) === null || _a === void 0 ? void 0 : _a.call(this, IndexdbStatus.CONNECT_ING);
39
+ request.onblocked = (evt) => {
40
+ var _a, _b;
41
+ logger.warn(`onblocked change from ${evt.oldVersion} to ${evt.newVersion}`, evt);
42
+ (_a = this.eventMap.process) === null || _a === void 0 ? void 0 : _a.call(this, IndexdbStatus.CONNECT_CLOSE);
43
+ (_b = this.eventMap.blocked) === null || _b === void 0 ? void 0 : _b.call(this, evt);
44
+ };
45
+ let returnVal = void 0;
46
+ request.onupgradeneeded = (event) => {
47
+ var _a, _b;
48
+ logger.info(`Version change from <${event.oldVersion}> to <${event.newVersion}>`, event);
49
+ (_a = this.eventMap.process) === null || _a === void 0 ? void 0 : _a.call(this, IndexdbStatus.VERSION_CHANGE);
50
+ const target = event.target;
51
+ this.idbDatabase = target.result;
52
+ (_b = this.eventMap.change) === null || _b === void 0 ? void 0 : _b.call(this, this.idbDatabase, event);
53
+ returnVal = upgrade === null || upgrade === void 0 ? void 0 : upgrade(this.idbDatabase, event);
54
+ };
55
+ return new Promise((resolve, reject) => {
56
+ request.onerror = (e) => {
57
+ var _a, _b;
58
+ logger.error('onerror', e);
59
+ (_a = this.eventMap.process) === null || _a === void 0 ? void 0 : _a.call(this, IndexdbStatus.CONNECT_ERROR);
60
+ (_b = this.eventMap.error) === null || _b === void 0 ? void 0 : _b.call(this, e);
61
+ reject(e);
62
+ };
63
+ request.onsuccess = (e) => {
64
+ var _a, _b;
65
+ logger.debug(`Connect Success`, e);
66
+ const target = e.target;
67
+ let connect = target.result;
68
+ this.idbDatabase = connect;
69
+ let objectStoreNames = connect.objectStoreNames;
70
+ if (objectStoreNames.length) {
71
+ let transaction = connect.transaction(objectStoreNames);
72
+ for (let i = 0; i < objectStoreNames.length; i++) {
73
+ let table = objectStoreNames.item(i);
74
+ if (!table)
75
+ continue;
76
+ let objectStore = transaction.objectStore(table);
77
+ let { indexNames, keyPath: primaryKey, name, autoIncrement = true } = objectStore;
78
+ let indexes = [];
79
+ for (let j = 0; indexNames && j < indexNames.length; j++) {
80
+ let indexName = indexNames.item(j);
81
+ if (!indexName)
82
+ continue;
83
+ let { keyPath, name, multiEntry, unique } = objectStore.index(indexName);
84
+ indexes.push({ name, column: keyPath, unique, multiEntry });
85
+ }
86
+ this.tableMap.set(name, new Table({
87
+ name,
88
+ primaryKey: primaryKey == null ? void 0 : primaryKey,
89
+ autoIncrement,
90
+ indexes
91
+ }, this.idbDatabase));
92
+ }
93
+ transaction.commit();
94
+ }
95
+ (_a = this.eventMap.process) === null || _a === void 0 ? void 0 : _a.call(this, IndexdbStatus.CONNECT_SUCCESS);
96
+ (_b = this.eventMap.success) === null || _b === void 0 ? void 0 : _b.call(this, this.idbDatabase);
97
+ resolve(returnVal || this);
98
+ };
99
+ });
100
+ });
101
+ }
102
+ drop() {
103
+ return new Promise((resolve, reject) => {
104
+ let request = innerDB.deleteDatabase(this.name);
105
+ request.onerror = function (event) {
106
+ reject(event);
107
+ };
108
+ request.onsuccess = function (event) {
109
+ resolve(event);
110
+ };
111
+ this.close();
112
+ });
113
+ }
114
+ close() {
115
+ var _a, _b, _c;
116
+ if (this.connected) {
117
+ (_a = this.eventMap.process) === null || _a === void 0 ? void 0 : _a.call(this, IndexdbStatus.CONNECT_CLOSE);
118
+ (_b = this.idbDatabase) === null || _b === void 0 ? void 0 : _b.close();
119
+ (_c = this.eventMap.close) === null || _c === void 0 ? void 0 : _c.call(this);
120
+ this.idbDatabase = void 0;
121
+ }
122
+ }
123
+ createTable(tableName_1) {
124
+ return __awaiter(this, arguments, void 0, function* (tableName, meta = {}, idbDatabase) {
125
+ var _a, _b;
126
+ const { overwrite = false } = meta;
127
+ if (!overwrite && this.exists(tableName)) {
128
+ throw new Error(`Table ${tableName} is exists`);
129
+ }
130
+ const metadata = Object.assign(Object.assign({}, meta), { name: tableName });
131
+ let { name = '', primaryKey = 'id', autoIncrement = true, indexes = [], rows = [] } = metadata;
132
+ const store = (_a = (idbDatabase || this.idbDatabase)) === null || _a === void 0 ? void 0 : _a.createObjectStore(name, { keyPath: primaryKey, autoIncrement });
133
+ let idxes = indexes.map(({ name, column, unique, multiEntry }) => {
134
+ store === null || store === void 0 ? void 0 : store.createIndex(name, column, { unique, multiEntry });
135
+ return { name, column, unique, multiEntry };
136
+ });
137
+ (_b = metadata.rows) === null || _b === void 0 ? void 0 : _b.forEach(row => store === null || store === void 0 ? void 0 : store.add(row));
138
+ let table = new Table({ name, primaryKey, autoIncrement, indexes: idxes }, idbDatabase || this.idbDatabase);
139
+ this.tableMap.set(name, table);
140
+ return table;
141
+ });
142
+ }
143
+ createTables(tables_1) {
144
+ return __awaiter(this, arguments, void 0, function* (tables, meta = {}, idbDatabase) {
145
+ return new Promise((resolve) => {
146
+ const createTables = (idbDatabase) => __awaiter(this, void 0, void 0, function* () {
147
+ let list = yield Promise.all(tables.map(table => {
148
+ if (typeof table === 'string') {
149
+ return this.createTable(table, meta, idbDatabase);
150
+ }
151
+ else {
152
+ return this.createTable(table.name, Object.assign(Object.assign({}, meta), table), idbDatabase);
153
+ }
154
+ }));
155
+ resolve(list);
156
+ });
157
+ if (idbDatabase) {
158
+ createTables(idbDatabase);
159
+ }
160
+ else {
161
+ this.connect(this.name, ++this.version, createTables);
162
+ }
163
+ });
164
+ });
165
+ }
166
+ dropTable(tableName) {
167
+ var _a;
168
+ if (this.exists(tableName)) {
169
+ (_a = this.idbDatabase) === null || _a === void 0 ? void 0 : _a.deleteObjectStore(tableName);
170
+ this.tableMap.delete(tableName);
171
+ return true;
172
+ }
173
+ logger.error(`Table ${tableName} is not exists`);
174
+ throw new Error(`Table ${tableName} is not exists`);
175
+ }
176
+ table(tableName) {
177
+ const table = this.tableMap.get(tableName);
178
+ if (!table) {
179
+ logger.error(`Table ${tableName} is not exists`);
180
+ throw new Error(`Table ${tableName} is not exists`);
181
+ }
182
+ return table;
183
+ }
184
+ exists(table) {
185
+ return this.tableMap.has(table);
186
+ }
187
+ getTables() {
188
+ return [...this.tableMap.values()];
189
+ }
190
+ }
package/lib/const.d.ts CHANGED
@@ -9,13 +9,13 @@ export declare enum IndexdbStatus {
9
9
  VERSION_CHANGE = 99
10
10
  }
11
11
  export declare class KeyRange {
12
- static leq(x: any): IDBKeyRange;
13
- static lt(x: any): IDBKeyRange;
14
- static geq(x: any): IDBKeyRange;
15
- static gt(x: any): IDBKeyRange;
16
- static between(x: any, y: any): IDBKeyRange;
17
- static gt_lt(x: any, y: any): IDBKeyRange;
18
- static gt_leq(x: any, y: any): IDBKeyRange;
19
- static geq_lt(x: any, y: any): IDBKeyRange;
20
- static eq(x: any, y: any): IDBKeyRange;
12
+ static leq(val: any): IDBKeyRange;
13
+ static lt(val: any): IDBKeyRange;
14
+ static geq(val: any): IDBKeyRange;
15
+ static gt(val: any): IDBKeyRange;
16
+ static between(low: any, upper: any): IDBKeyRange;
17
+ static gt_lt(low: any, upper: any): IDBKeyRange;
18
+ static gt_leq(low: any, upper: any): IDBKeyRange;
19
+ static geq_lt(low: any, upper: any): IDBKeyRange;
20
+ static eq(val: any): IDBKeyRange;
21
21
  }
package/lib/const.js CHANGED
@@ -11,31 +11,31 @@ export var IndexdbStatus;
11
11
  IndexdbStatus[IndexdbStatus["VERSION_CHANGE"] = 99] = "VERSION_CHANGE";
12
12
  })(IndexdbStatus || (IndexdbStatus = {}));
13
13
  export class KeyRange {
14
- static leq(x) {
15
- return IDBKeyRange.upperBound(x);
14
+ static leq(val) {
15
+ return IDBKeyRange.upperBound(val);
16
16
  }
17
- static lt(x) {
18
- return IDBKeyRange.upperBound(x, true);
17
+ static lt(val) {
18
+ return IDBKeyRange.upperBound(val, true);
19
19
  }
20
- static geq(x) {
21
- return IDBKeyRange.lowerBound(x);
20
+ static geq(val) {
21
+ return IDBKeyRange.lowerBound(val);
22
22
  }
23
- static gt(x) {
24
- return IDBKeyRange.lowerBound(x, true);
23
+ static gt(val) {
24
+ return IDBKeyRange.lowerBound(val, true);
25
25
  }
26
- static between(x, y) {
27
- return IDBKeyRange.bound(x, y);
26
+ static between(low, upper) {
27
+ return IDBKeyRange.bound(low, upper);
28
28
  }
29
- static gt_lt(x, y) {
30
- return IDBKeyRange.bound(x, y, true, true);
29
+ static gt_lt(low, upper) {
30
+ return IDBKeyRange.bound(low, upper, true, true);
31
31
  }
32
- static gt_leq(x, y) {
33
- return IDBKeyRange.bound(x, y, true, false);
32
+ static gt_leq(low, upper) {
33
+ return IDBKeyRange.bound(low, upper, true, false);
34
34
  }
35
- static geq_lt(x, y) {
36
- return IDBKeyRange.bound(x, y, false, true);
35
+ static geq_lt(low, upper) {
36
+ return IDBKeyRange.bound(low, upper, false, true);
37
37
  }
38
- static eq(x, y) {
39
- return IDBKeyRange.only(x);
38
+ static eq(val) {
39
+ return IDBKeyRange.only(val);
40
40
  }
41
41
  }
package/lib/database.d.ts CHANGED
@@ -1,31 +1,18 @@
1
- import { IndexdbStatus } from "./const";
2
- import Table, { Metadata } from "./table";
3
- interface EventMap {
4
- process: (this: Database, status: IndexdbStatus) => void;
5
- success: (this: Database, connect: IDBDatabase) => void;
6
- blocked: (this: Database, event: IDBVersionChangeEvent) => void;
7
- change: (connect: any) => void;
8
- error: (evt: Event) => void;
9
- close: () => void;
1
+ import Connection from "./connection";
2
+ import { Row, Pagination, RowPacket } from "./table";
3
+ export default class Database extends Connection {
4
+ query<R extends Row>(table: string, query?: IDBValidKey | IDBKeyRange, count?: number): Promise<RowPacket<R>>;
5
+ select<R extends Row>(table: string, key?: IDBValidKey | IDBKeyRange, index?: string, count?: number): Promise<RowPacket<R>>;
6
+ queryByKey<R extends Row>(table: string, key: IDBValidKey | IDBKeyRange): Promise<RowPacket<R>>;
7
+ queryByIndex<R extends Row>(table: string, indexName: string, key?: IDBValidKey | IDBKeyRange, count?: number): Promise<RowPacket<R>>;
8
+ queryById<R extends Row>(table: string, id: any | Array<any>, indexName?: string): Promise<R>;
9
+ count(table: string, key: IDBValidKey | IDBKeyRange): Promise<number>;
10
+ insert(table: string, data: Array<Record<string, any>>): Promise<IDBValidKey[]>;
11
+ update(table: string, modify: Row, key?: IDBValidKey | IDBKeyRange | null): Promise<IDBValidKey>;
12
+ delete(table: string, key: IDBValidKey | IDBKeyRange): Promise<any[]>;
13
+ truncate(table: string): Promise<void>;
14
+ getPagination<R extends Row>(table: string, pageSize?: number): Promise<Pagination<R>>;
15
+ scan<R extends Row>(table: string, key?: IDBValidKey | IDBKeyRange, direction?: IDBCursorDirection, indexName?: string): Promise<RowPacket<R>>;
16
+ getAllData<R extends Row>(table: string): Promise<Array<R>>;
17
+ paginate<R extends Row>(table: string, pageNo?: number, pageSize?: number, key?: IDBValidKey | IDBKeyRange, indexName?: string): Promise<RowPacket<R>>;
10
18
  }
11
- type EventKey = keyof EventMap;
12
- export default class Database {
13
- private name;
14
- private version;
15
- database?: IDBDatabase;
16
- readonly tableMap: Map<string, Table>;
17
- private eventMap;
18
- constructor(database: string, version?: number);
19
- on<T extends EventKey>(event: T, handle: EventMap[T]): this;
20
- get connected(): boolean;
21
- connect(name?: string, version?: number): Promise<Database>;
22
- drop(): Promise<unknown>;
23
- close(): void;
24
- createTable(tableName: string, meta?: Omit<Metadata, 'name'>): Table;
25
- createTables(tables: Array<string>, meta?: Omit<Metadata, 'name' | 'rows'>): Table[];
26
- dropTable(tableName: string): boolean;
27
- table(tableName: string): Table | undefined;
28
- exists(table: string): boolean;
29
- getTables(): MapIterator<Table>;
30
- }
31
- export {};