Skip to content
This repository was archived by the owner on May 25, 2025. It is now read-only.

Commit 9325445

Browse files
feat: adapt to db-lib
1 parent 846f39f commit 9325445

File tree

5 files changed

+48
-11
lines changed

5 files changed

+48
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"url": "https://github.com/NaturalCycles/sqlite-lib"
4242
},
4343
"engines": {
44-
"node": ">=18.12.0"
44+
"node": ">=20.13.0"
4545
},
4646
"version": "1.2.1",
4747
"description": "CommonDB implementation based on SQLite",

src/betterSqliteKeyValueDB.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import { CommonDBCreateOptions, CommonKeyValueDB, KeyValueDBTuple } from '@naturalcycles/db-lib'
2-
import { AppError, CommonLogger } from '@naturalcycles/js-lib'
1+
import {
2+
CommonDBCreateOptions,
3+
CommonKeyValueDB,
4+
commonKeyValueDBFullSupport,
5+
KeyValueDBTuple,
6+
} from '@naturalcycles/db-lib'
7+
import { AppError, CommonLogger, StringMap } from '@naturalcycles/js-lib'
38
import { boldWhite, readableCreate, ReadableTyped } from '@naturalcycles/nodejs-lib'
49
import type { Database, Options } from 'better-sqlite3'
510
import BetterSqlite3 from 'better-sqlite3'
@@ -38,6 +43,11 @@ export class BetterSqliteKeyValueDB implements CommonKeyValueDB {
3843

3944
cfg: BetterSQLiteKeyValueDBCfg & { logger: CommonLogger }
4045

46+
support = {
47+
...commonKeyValueDBFullSupport,
48+
increment: false, // todo: can be supported
49+
}
50+
4151
_db?: Database
4252

4353
get db(): Database {
@@ -196,4 +206,11 @@ export class BetterSqliteKeyValueDB implements CommonKeyValueDB {
196206
async increment(_table: string, _id: string, _by?: number): Promise<number> {
197207
throw new AppError('Not implemented')
198208
}
209+
210+
async incrementBatch(
211+
_table: string,
212+
_incrementMap: StringMap<number>,
213+
): Promise<StringMap<number>> {
214+
throw new AppError('Not implemented')
215+
}
199216
}

src/sqlite.db.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export interface SQLiteDBCfg {
2828
logger?: CommonLogger
2929
}
3030

31+
/**
32+
* todo: Warning: this implementation is incomplete!
33+
*/
3134
export class SQLiteDB extends BaseCommonDB implements CommonDB {
3235
constructor(cfg: SQLiteDBCfg) {
3336
super()

src/sqliteKeyValueDB.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import { CommonDBCreateOptions, CommonKeyValueDB, KeyValueDBTuple } from '@naturalcycles/db-lib'
2-
import { AppError, CommonLogger, pMap } from '@naturalcycles/js-lib'
1+
import {
2+
CommonDBCreateOptions,
3+
CommonKeyValueDB,
4+
commonKeyValueDBFullSupport,
5+
KeyValueDBTuple,
6+
} from '@naturalcycles/db-lib'
7+
import { AppError, CommonLogger, pMap, StringMap } from '@naturalcycles/js-lib'
38
import { boldWhite, readableCreate, ReadableTyped } from '@naturalcycles/nodejs-lib'
49
import { Database, open } from 'sqlite'
510
import * as sqlite3 from 'sqlite3'
@@ -48,6 +53,11 @@ export class SqliteKeyValueDB implements CommonKeyValueDB {
4853

4954
cfg: SQLiteKeyValueDBCfg & { logger: CommonLogger }
5055

56+
support = {
57+
...commonKeyValueDBFullSupport,
58+
increment: false, // todo: can be implemented
59+
}
60+
5161
_db?: Database
5262

5363
get db(): Database {
@@ -219,4 +229,11 @@ export class SqliteKeyValueDB implements CommonKeyValueDB {
219229
async increment(_table: string, _id: string, _by?: number): Promise<number> {
220230
throw new AppError('Not implemented')
221231
}
232+
233+
async incrementBatch(
234+
_table: string,
235+
_incrementMap: StringMap<number>,
236+
): Promise<StringMap<number>> {
237+
throw new AppError('Not implemented')
238+
}
222239
}

yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,17 +1007,17 @@
10071007
typescript "^5.0.2"
10081008

10091009
"@naturalcycles/db-lib@^9.1.0":
1010-
version "9.20.0"
1011-
resolved "https://registry.yarnpkg.com/@naturalcycles/db-lib/-/db-lib-9.20.0.tgz#659d1d12e72f587e47e8197cdeea18ce6e40156c"
1012-
integrity sha512-FjTTEy3vHOGyrA4394N1pTKd6BVjwa77jpUpZaqPOfwJ4EzNksDaUSND4j6apbfCaAnoIeaAPM268fK3vgMuYQ==
1010+
version "9.22.0"
1011+
resolved "https://registry.yarnpkg.com/@naturalcycles/db-lib/-/db-lib-9.22.0.tgz#d01153b033e22155ade705aa049fe089978c5798"
1012+
integrity sha512-989fWQqlfMrtoaKxzqWN2Eh7Y7MrJcqoq5wl7Uldm84eUe3OUY87H0BYgGr/1kO309l2EuzhEkkEzcuO9QyKJw==
10131013
dependencies:
10141014
"@naturalcycles/js-lib" "^14.116.0"
10151015
"@naturalcycles/nodejs-lib" "^13.1.1"
10161016

10171017
"@naturalcycles/dev-lib@^15.21.0":
1018-
version "15.21.0"
1019-
resolved "https://registry.yarnpkg.com/@naturalcycles/dev-lib/-/dev-lib-15.21.0.tgz#da26103e4b8c65ead643a668fead7433e86555ae"
1020-
integrity sha512-0eGFi4XuDtdj4kuO0cANmlbtr3Q4La6g6UHZnV85xZB7CZbqVZ1Si46l2RBnqP0F//8tgP3YLZMPpmyWFAte0g==
1018+
version "15.22.0"
1019+
resolved "https://registry.yarnpkg.com/@naturalcycles/dev-lib/-/dev-lib-15.22.0.tgz#f1a31b5e0483e2d5beaadf8e5bce9345789b9fef"
1020+
integrity sha512-QZQEvP2yM27hDATOOHoaNDXXphUwt/dDMbVd7RATQMGoSmjV8QYANJSisWLPAVAee1eF+yQ+t/SUDNrtFoLSXg==
10211021
dependencies:
10221022
"@biomejs/biome" "^1.8.3"
10231023
"@commitlint/cli" "^19.0.0"

0 commit comments

Comments
 (0)