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

Commit 670333d

Browse files
fix: deps
1 parent b35ee00 commit 670333d

File tree

2 files changed

+33
-36
lines changed

2 files changed

+33
-36
lines changed

src/mysql.db.ts

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ import {
2020
_mapValues,
2121
_Memo,
2222
_omit,
23-
AnyObjectWithId,
23+
AnyPartialObjectWithId,
2424
CommonLogger,
2525
commonLoggerPrefix,
2626
JsonSchemaObject,
2727
JsonSchemaRootObject,
28-
ObjectWithId,
28+
PartialObjectWithId,
29+
Saved,
2930
} from '@naturalcycles/js-lib'
3031
import { ReadableTyped, white } from '@naturalcycles/nodejs-lib'
3132
import {
@@ -47,7 +48,7 @@ import {
4748
} from './schema/mysql.schema.util'
4849

4950
export interface MysqlDBOptions extends CommonDBOptions {}
50-
export interface MysqlDBSaveOptions<ROW extends Partial<ObjectWithId> = AnyObjectWithId>
51+
export interface MysqlDBSaveOptions<ROW extends PartialObjectWithId = AnyPartialObjectWithId>
5152
extends CommonDBSaveOptions<ROW> {}
5253

5354
/**
@@ -195,22 +196,22 @@ export class MysqlDB extends BaseCommonDB implements CommonDB {
195196
}
196197

197198
// GET
198-
override async getByIds<ROW extends ObjectWithId>(
199+
override async getByIds<ROW extends PartialObjectWithId>(
199200
table: string,
200-
ids: ROW['id'][],
201+
ids: string[],
201202
opt: MysqlDBOptions = {},
202-
): Promise<ROW[]> {
203+
): Promise<Saved<ROW>[]> {
203204
if (!ids.length) return []
204205
const q = new DBQuery<ROW>(table).filterEq('id', ids)
205206
const { rows } = await this.runQuery(q, opt)
206207
return rows.map(r => _mapKeys(r, k => mapNameFromMySQL(k as string)) as any)
207208
}
208209

209210
// QUERY
210-
override async runQuery<ROW extends ObjectWithId, OUT = ROW>(
211+
override async runQuery<ROW extends PartialObjectWithId>(
211212
q: DBQuery<ROW>,
212213
_opt: MysqlDBOptions = {},
213-
): Promise<RunQueryResult<OUT>> {
214+
): Promise<RunQueryResult<Saved<ROW>>> {
214215
const sql = dbQueryToSQLSelect(q)
215216
if (!sql) {
216217
return {
@@ -260,18 +261,18 @@ export class MysqlDB extends BaseCommonDB implements CommonDB {
260261
}
261262
}
262263

263-
override async runQueryCount<ROW extends ObjectWithId>(
264+
override async runQueryCount<ROW extends PartialObjectWithId>(
264265
q: DBQuery<ROW>,
265266
_opt?: CommonDBOptions,
266267
): Promise<number> {
267268
const { rows } = await this.runQuery(q.select(['count(*) as _count' as any]))
268269
return (rows[0] as any)._count
269270
}
270271

271-
override streamQuery<ROW extends ObjectWithId, OUT = ROW>(
272+
override streamQuery<ROW extends PartialObjectWithId>(
272273
q: DBQuery<ROW>,
273274
_opt: MysqlDBOptions = {},
274-
): ReadableTyped<OUT> {
275+
): ReadableTyped<Saved<ROW>> {
275276
const sql = dbQueryToSQLSelect(q)
276277
if (!sql) {
277278
return Readable.from([])
@@ -294,7 +295,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB {
294295
}
295296

296297
// SAVE
297-
override async saveBatch<ROW extends Partial<ObjectWithId>>(
298+
override async saveBatch<ROW extends PartialObjectWithId>(
298299
table: string,
299300
rowsInput: ROW[],
300301
opt: MysqlDBSaveOptions<ROW> = {},
@@ -363,11 +364,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB {
363364
/**
364365
* Limitation: always returns [], regardless of which rows are actually deleted
365366
*/
366-
override async deleteByIds<ROW extends ObjectWithId>(
367-
table: string,
368-
ids: ROW['id'][],
369-
_opt?: MysqlDBOptions,
370-
): Promise<number> {
367+
override async deleteByIds(table: string, ids: string[], _opt?: MysqlDBOptions): Promise<number> {
371368
if (!ids.length) return 0
372369
const sql = dbQueryToSQLDelete(new DBQuery(table).filterEq('id', ids))
373370
if (!sql) return 0
@@ -376,7 +373,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB {
376373
return affectedRows
377374
}
378375

379-
override async deleteByQuery<ROW extends ObjectWithId>(
376+
override async deleteByQuery<ROW extends PartialObjectWithId>(
380377
q: DBQuery<ROW>,
381378
_opt?: CommonDBOptions,
382379
): Promise<number> {
@@ -396,7 +393,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB {
396393
/**
397394
* dropIfExists=true needed as a safety check
398395
*/
399-
override async createTable<ROW extends ObjectWithId>(
396+
override async createTable<ROW extends PartialObjectWithId>(
400397
table: string,
401398
schema: JsonSchemaObject<ROW>,
402399
opt: CommonDBCreateOptions = {},
@@ -413,7 +410,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB {
413410
.filter(Boolean)
414411
}
415412

416-
override async getTableSchema<ROW extends ObjectWithId>(
413+
override async getTableSchema<ROW extends PartialObjectWithId>(
417414
table: string,
418415
): Promise<JsonSchemaRootObject<ROW>> {
419416
const stats = await this.runSQL<MySQLTableStats[]>({
@@ -423,7 +420,7 @@ export class MysqlDB extends BaseCommonDB implements CommonDB {
423420
return mysqlTableStatsToJsonSchemaField<ROW>(table, stats, this.cfg.logger)
424421
}
425422

426-
override async updateByQuery<ROW extends ObjectWithId>(
423+
override async updateByQuery<ROW extends PartialObjectWithId>(
427424
q: DBQuery<ROW>,
428425
patch: DBPatch<ROW>,
429426
): Promise<number> {

yarn.lock

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -799,9 +799,9 @@
799799
typescript "^5.0.2"
800800

801801
"@naturalcycles/db-lib@^9.1.0":
802-
version "9.1.0"
803-
resolved "https://registry.yarnpkg.com/@naturalcycles/db-lib/-/db-lib-9.1.0.tgz#4c2d206301caeb67381713566d1945df91435a1f"
804-
integrity sha512-qAJai7bRWY37+Wo/p8KyxaJ+d1UE2XIgIZoc8dcdYtB3XyEUjz3ZNNA4GeurgtxOBqeD5U0UxcOHbijJaHyzCg==
802+
version "9.3.0"
803+
resolved "https://registry.yarnpkg.com/@naturalcycles/db-lib/-/db-lib-9.3.0.tgz#d6727ff62b4150f26e83e3b68e5ca975229f154d"
804+
integrity sha512-wcPFWmQ+jXtdXrSqPuXHnkzw4UjwvJUhtIIWFxLdsaoEFnA8peSsdpH+E5QIU7EDjXfQmYQ6nhcacmWQ6NvM+Q==
805805
dependencies:
806806
"@naturalcycles/js-lib" "^14.116.0"
807807
"@naturalcycles/nodejs-lib" "^13.1.1"
@@ -842,9 +842,9 @@
842842
yargs "^17.0.0"
843843

844844
"@naturalcycles/js-lib@^14.0.0", "@naturalcycles/js-lib@^14.116.0", "@naturalcycles/js-lib@^14.47.0":
845-
version "14.201.1"
846-
resolved "https://registry.yarnpkg.com/@naturalcycles/js-lib/-/js-lib-14.201.1.tgz#67d7b74be557385736b489c4ab6f318cf8d093cf"
847-
integrity sha512-NAxPDWxNiFs8Eidj4vt0jcRyvLJ2MuHmPuryIETvKRLfdQ3j14XfZbvCtNMfmX1Yfl0an0xE5fKN2yzKKJk0LQ==
845+
version "14.204.1"
846+
resolved "https://registry.yarnpkg.com/@naturalcycles/js-lib/-/js-lib-14.204.1.tgz#d81838e4a8cd889b734637c2b26a750d5758ef10"
847+
integrity sha512-+2E30+MKFdlxnkbsBHBcbi8aTTPl3AZRe+NUzgimJoJw+7wJS0k6v2DVbrmQ1MCcEyQ4gV5jhOQT8iHEtDDSDw==
848848
dependencies:
849849
tslib "^2.0.0"
850850
zod "^3.20.2"
@@ -1642,9 +1642,9 @@ camelcase@^6.2.0:
16421642
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==
16431643

16441644
caniuse-lite@^1.0.30001565:
1645-
version "1.0.30001578"
1646-
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001578.tgz#11741580434ce60aae4b4a9abee9f9f8d7bf5be5"
1647-
integrity sha512-J/jkFgsQ3NEl4w2lCoM9ZPxrD+FoBNJ7uJUpGVjIg/j0OwJosWM36EPDv+Yyi0V4twBk9pPmlFS+PLykgEvUmg==
1645+
version "1.0.30001579"
1646+
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001579.tgz#45c065216110f46d6274311a4b3fcf6278e0852a"
1647+
integrity sha512-u5AUVkixruKHJjw/pj9wISlcMpgFWzSrczLZbrqBSxukQixmg0SJ5sZTpvaFvxU0HoQKd4yoyAogyrAz9pzJnA==
16481648

16491649
chalk@5.3.0:
16501650
version "5.3.0"
@@ -1992,9 +1992,9 @@ ecdsa-sig-formatter@1.0.11:
19921992
safe-buffer "^5.0.1"
19931993

19941994
electron-to-chromium@^1.4.601:
1995-
version "1.4.636"
1996-
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.636.tgz#302cf4c3016d9d714ba246243a7c97b528e22fe7"
1997-
integrity sha512-NLE0GIy1OL9wRiKL20h9TkctBEYZuc99tquSS9MVdTahnuHputoETHeqDzgqGqyOY9NUH0g9wjfEuw5OD+wRcQ==
1995+
version "1.4.639"
1996+
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.639.tgz#c6f9cc685f9efb2980d2cfc95a27f8142c9adf28"
1997+
integrity sha512-CkKf3ZUVZchr+zDpAlNLEEy2NJJ9T64ULWaDgy3THXXlPVPkLu3VOs9Bac44nebVtdwl2geSj6AxTtGDOxoXhg==
19981998

19991999
emittery@^0.13.1:
20002000
version "0.13.1"
@@ -3410,9 +3410,9 @@ jiti@^1.19.1:
34103410
integrity sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q==
34113411

34123412
joi@^17.9.2:
3413-
version "17.11.1"
3414-
resolved "https://registry.yarnpkg.com/joi/-/joi-17.11.1.tgz#f42951137d25c27f61807502b0af71f7abb885ba"
3415-
integrity sha512-671acnrx+w96PCcQOzvm0VYQVwNL2PVgZmDRaFuSsx8sIUmGzYElPw5lU8F3Cr0jOuPs1oM56p7W2a1cdDOwcw==
3413+
version "17.12.0"
3414+
resolved "https://registry.yarnpkg.com/joi/-/joi-17.12.0.tgz#a3fb5715f198beb0471cd551dd26792089c308d5"
3415+
integrity sha512-HSLsmSmXz+PV9PYoi3p7cgIbj06WnEBNT28n+bbBNcPZXZFqCzzvGqpTBPujx/Z0nh1+KNQPDrNgdmQ8dq0qYw==
34163416
dependencies:
34173417
"@hapi/hoek" "^9.3.0"
34183418
"@hapi/topo" "^5.1.0"

0 commit comments

Comments
 (0)