Skip to content

Commit

Permalink
fix: adapt to latest db-lib changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Apr 16, 2022
1 parent 0e67249 commit a847942
Show file tree
Hide file tree
Showing 6 changed files with 1,199 additions and 1,164 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
if: "!contains(github.event.head_commit.message, 'skip ci')"
env: { NODE_OPTIONS: '--max-old-space-size=3200' }
steps:
- { uses: actions/checkout@v2, with: { persist-credentials: true } }
- { uses: actions/setup-node@v2, with: { node-version: 16, cache: 'yarn' } }
- { uses: actions/checkout@v3, with: { persist-credentials: true } }
- { uses: actions/setup-node@v3, with: { node-version: 16, cache: 'yarn' } }

# Cache for npm/npx in ~/.npm
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: ~/.npm
key: npm-v1-${{ runner.os }}
Expand Down
10 changes: 5 additions & 5 deletions src/datastore.db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {

override async getByIds<ROW extends ObjectWithId>(
table: string,
ids: string[],
ids: ROW['id'][],
_opt?: DatastoreDBOptions,
): Promise<ROW[]> {
if (!ids.length) return []
Expand Down Expand Up @@ -302,9 +302,9 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
* Limitation: Datastore's delete returns void, so we always return all ids here as "deleted"
* regardless if they were actually deleted or not.
*/
override async deleteByIds(
override async deleteByIds<ROW extends ObjectWithId>(
table: string,
ids: string[],
ids: ROW['id'][],
opt: DatastoreDBOptions = {},
): Promise<number> {
const keys = ids.map(id => this.key(table, id))
Expand Down Expand Up @@ -386,7 +386,7 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
// if key field exists on entity, it will be used as key (prevent to duplication of numeric keyed entities)
toDatastoreEntity<T = any>(
kind: string,
o: T & { id?: string },
o: T & { id?: string | number },
excludeFromIndexes: string[] = [],
): DatastorePayload<T> {
const key = this.getDsKey(o) || this.key(kind, o.id!)
Expand All @@ -401,7 +401,7 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
}
}

key(kind: string, id: string): Key {
key(kind: string, id: string | number): Key {
_assert(id, `Cannot save "${kind}" entity without "id"`)
return this.ds().key([kind, String(id)])
}
Expand Down
2 changes: 1 addition & 1 deletion src/datastoreKeyValueDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class DatastoreKeyValueDB implements CommonKeyValueDB {
.limit(limit || 0)

return this.db.streamQuery<KVObject>(q).pipe(
transformMapSimple<ObjectWithId, string>(objectWithId => objectWithId.id, {
transformMapSimple<ObjectWithId<string>, string>(objectWithId => objectWithId.id, {
errorMode: ErrorMode.SUPPRESS, // cause .pipe() cannot propagate errors
}),
)
Expand Down
2 changes: 1 addition & 1 deletion src/test/datastore.manual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const features: CommonDBImplementationFeatures = {
}
const quirks: CommonDBImplementationQuirks = {
// 2021-10-07: fails when set to 100, bumped up to 300
eventualConsistencyDelay: 300,
// eventualConsistencyDelay: 300,
}

describe('runCommonDBTest', () => runCommonDBTest(datastoreDB, features, quirks))
Expand Down
10 changes: 0 additions & 10 deletions src/test/getdb.manual.test.ts

This file was deleted.

Loading

0 comments on commit a847942

Please sign in to comment.