@naturalcycles/firestore-lib 1.1.5 → 1.1.6
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/CHANGELOG.md +7 -0
- package/dist/firestore.db.d.ts +3 -3
- package/package.json +1 -1
- package/src/firestore.db.ts +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.1.6](https://github.com/NaturalCycles/firestore-lib/compare/v1.1.5...v1.1.6) (2021-10-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* db-lib compat ([ad28580](https://github.com/NaturalCycles/firestore-lib/commit/ad28580cf772b9ff05d07cc89e6ee19be52981e3))
|
|
7
|
+
|
|
1
8
|
## [1.1.5](https://github.com/NaturalCycles/firestore-lib/compare/v1.1.4...v1.1.5) (2021-10-17)
|
|
2
9
|
|
|
3
10
|
|
package/dist/firestore.db.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Query } from '@google-cloud/firestore';
|
|
2
|
-
import { BaseCommonDB, CommonDB, CommonDBOptions, CommonDBSaveOptions, CommonDBStreamOptions, DBQuery, DBTransaction, ObjectWithId, RunQueryResult } from '@naturalcycles/db-lib';
|
|
2
|
+
import { BaseCommonDB, CommonDB, CommonDBOptions, CommonDBSaveOptions, CommonDBStreamOptions, DBQuery, DBTransaction, ObjectWithId, RunQueryResult, AnyObjectWithId } from '@naturalcycles/db-lib';
|
|
3
3
|
import { ReadableTyped } from '@naturalcycles/nodejs-lib';
|
|
4
4
|
import * as firebaseAdmin from 'firebase-admin';
|
|
5
5
|
export interface FirestoreDBCfg {
|
|
@@ -7,7 +7,7 @@ export interface FirestoreDBCfg {
|
|
|
7
7
|
}
|
|
8
8
|
export interface FirestoreDBOptions extends CommonDBOptions {
|
|
9
9
|
}
|
|
10
|
-
export interface FirestoreDBSaveOptions extends CommonDBSaveOptions {
|
|
10
|
+
export interface FirestoreDBSaveOptions<ROW extends ObjectWithId = AnyObjectWithId> extends CommonDBSaveOptions<ROW> {
|
|
11
11
|
}
|
|
12
12
|
export declare class FirestoreDB extends BaseCommonDB implements CommonDB {
|
|
13
13
|
cfg: FirestoreDBCfg;
|
|
@@ -18,7 +18,7 @@ export declare class FirestoreDB extends BaseCommonDB implements CommonDB {
|
|
|
18
18
|
runFirestoreQuery<ROW extends ObjectWithId>(q: Query, _opt?: FirestoreDBOptions): Promise<ROW[]>;
|
|
19
19
|
runQueryCount<ROW extends ObjectWithId>(q: DBQuery<ROW>, opt?: FirestoreDBOptions): Promise<number>;
|
|
20
20
|
streamQuery<ROW extends ObjectWithId>(q: DBQuery<ROW>, _opt?: CommonDBStreamOptions): ReadableTyped<ROW>;
|
|
21
|
-
saveBatch<ROW extends ObjectWithId>(table: string, rows: ROW[], _opt?: FirestoreDBSaveOptions): Promise<void>;
|
|
21
|
+
saveBatch<ROW extends ObjectWithId>(table: string, rows: ROW[], _opt?: FirestoreDBSaveOptions<ROW>): Promise<void>;
|
|
22
22
|
deleteByQuery<ROW extends ObjectWithId>(q: DBQuery<ROW>, opt?: FirestoreDBOptions): Promise<number>;
|
|
23
23
|
deleteByIds(table: string, ids: string[], _opt?: FirestoreDBOptions): Promise<number>;
|
|
24
24
|
private querySnapshotToArray;
|
package/package.json
CHANGED
package/src/firestore.db.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
DBTransaction,
|
|
10
10
|
ObjectWithId,
|
|
11
11
|
RunQueryResult,
|
|
12
|
+
AnyObjectWithId,
|
|
12
13
|
} from '@naturalcycles/db-lib'
|
|
13
14
|
import { ErrorMode, pMap, _chunk, _filterNullishValues, _omit } from '@naturalcycles/js-lib'
|
|
14
15
|
import { ReadableTyped, transformMapSimple } from '@naturalcycles/nodejs-lib'
|
|
@@ -21,7 +22,8 @@ export interface FirestoreDBCfg {
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export interface FirestoreDBOptions extends CommonDBOptions {}
|
|
24
|
-
export interface FirestoreDBSaveOptions extends
|
|
25
|
+
export interface FirestoreDBSaveOptions<ROW extends ObjectWithId = AnyObjectWithId>
|
|
26
|
+
extends CommonDBSaveOptions<ROW> {}
|
|
25
27
|
|
|
26
28
|
export class FirestoreDB extends BaseCommonDB implements CommonDB {
|
|
27
29
|
constructor(public cfg: FirestoreDBCfg) {
|
|
@@ -112,7 +114,7 @@ export class FirestoreDB extends BaseCommonDB implements CommonDB {
|
|
|
112
114
|
override async saveBatch<ROW extends ObjectWithId>(
|
|
113
115
|
table: string,
|
|
114
116
|
rows: ROW[],
|
|
115
|
-
_opt?: FirestoreDBSaveOptions
|
|
117
|
+
_opt?: FirestoreDBSaveOptions<ROW>,
|
|
116
118
|
): Promise<void> {
|
|
117
119
|
// Firestore allows max 500 items in one batch
|
|
118
120
|
await pMap(
|