@naturalcycles/firestore-lib 2.15.0 → 2.16.1
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/dist/firestore.db.js +5 -5
- package/dist/query.util.js +9 -2
- package/package.json +4 -4
- package/src/index.ts +1 -0
- package/src/query.util.ts +5 -1
package/dist/firestore.db.js
CHANGED
|
@@ -157,7 +157,7 @@ export class FirestoreDB extends BaseCommonDB {
|
|
|
157
157
|
}
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
160
|
-
await pMap(_chunk(rows, MAX_ITEMS), async chunk => {
|
|
160
|
+
await pMap(_chunk(rows, MAX_ITEMS), async (chunk) => {
|
|
161
161
|
// .batch is called "Atomic batch writer"
|
|
162
162
|
// Executes multiple writes in a single atomic transaction-like commit — all succeed or all fail.
|
|
163
163
|
// If any write in the batch fails (e.g., permission error, missing doc), the whole batch fails.
|
|
@@ -192,7 +192,7 @@ export class FirestoreDB extends BaseCommonDB {
|
|
|
192
192
|
tableRows.push([table, row]);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
await pMap(_chunk(tableRows, MAX_ITEMS), async chunk => {
|
|
195
|
+
await pMap(_chunk(tableRows, MAX_ITEMS), async (chunk) => {
|
|
196
196
|
const batch = firestore.batch();
|
|
197
197
|
for (const [table, row] of chunk) {
|
|
198
198
|
_assert(row.id, `firestore-db doesn't support id auto-generation, but empty id was provided in multiSaveBatch`);
|
|
@@ -236,7 +236,7 @@ export class FirestoreDB extends BaseCommonDB {
|
|
|
236
236
|
}
|
|
237
237
|
return ids.length;
|
|
238
238
|
}
|
|
239
|
-
await pMap(_chunk(ids, MAX_ITEMS), async chunk => {
|
|
239
|
+
await pMap(_chunk(ids, MAX_ITEMS), async (chunk) => {
|
|
240
240
|
const batch = firestore.batch();
|
|
241
241
|
for (const id of chunk) {
|
|
242
242
|
batch.delete(col.doc(escapeDocId(id)));
|
|
@@ -259,7 +259,7 @@ export class FirestoreDB extends BaseCommonDB {
|
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
else {
|
|
262
|
-
await pMap(_chunk(refs, MAX_ITEMS), async chunk => {
|
|
262
|
+
await pMap(_chunk(refs, MAX_ITEMS), async (chunk) => {
|
|
263
263
|
const batch = firestore.batch();
|
|
264
264
|
for (const ref of chunk) {
|
|
265
265
|
batch.delete(ref);
|
|
@@ -278,7 +278,7 @@ export class FirestoreDB extends BaseCommonDB {
|
|
|
278
278
|
async runInTransaction(fn, opt = {}) {
|
|
279
279
|
const { readOnly } = opt;
|
|
280
280
|
try {
|
|
281
|
-
await this.cfg.firestore.runTransaction(async firestoreTx => {
|
|
281
|
+
await this.cfg.firestore.runTransaction(async (firestoreTx) => {
|
|
282
282
|
const tx = new FirestoreDBTransaction(this, firestoreTx);
|
|
283
283
|
await fn(tx);
|
|
284
284
|
}, {
|
package/dist/query.util.js
CHANGED
|
@@ -12,7 +12,10 @@ export function readAtToReadTime(opt) {
|
|
|
12
12
|
}
|
|
13
13
|
// Map DBQueryFilterOp to WhereFilterOp
|
|
14
14
|
// Currently it's fully aligned!
|
|
15
|
-
const OP_MAP = {
|
|
15
|
+
const OP_MAP = {
|
|
16
|
+
// '=': '==',
|
|
17
|
+
// in: 'array-contains',
|
|
18
|
+
};
|
|
16
19
|
export function dbQueryToFirestoreQuery(dbQuery, emptyQuery) {
|
|
17
20
|
let q = emptyQuery;
|
|
18
21
|
// filter
|
|
@@ -24,7 +27,11 @@ export function dbQueryToFirestoreQuery(dbQuery, emptyQuery) {
|
|
|
24
27
|
q = q.orderBy(mapName(ord.name), ord.descending ? 'desc' : 'asc');
|
|
25
28
|
}
|
|
26
29
|
// limit
|
|
27
|
-
|
|
30
|
+
// Careful here, Firestore just changed the behavior of limit(0) recently!
|
|
31
|
+
// Therefor we're guarding the limit(0) case and not sending the limit if it's zero.
|
|
32
|
+
if (dbQuery._limitValue) {
|
|
33
|
+
q = q.limit(dbQuery._limitValue);
|
|
34
|
+
}
|
|
28
35
|
// selectedFields
|
|
29
36
|
if (dbQuery._selectedFieldNames) {
|
|
30
37
|
// id is filtered out, because in Firestore it's not a "property",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@naturalcycles/firestore-lib",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@google-cloud/firestore": "^
|
|
5
|
+
"@google-cloud/firestore": "^8",
|
|
6
6
|
"@naturalcycles/db-lib": "^10",
|
|
7
7
|
"@naturalcycles/js-lib": "^15",
|
|
8
8
|
"@naturalcycles/nodejs-lib": "^15",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@types/node": "^25",
|
|
13
|
-
"@typescript/native-preview": "
|
|
14
|
-
"firebase-admin": "^
|
|
13
|
+
"@typescript/native-preview": "beta",
|
|
14
|
+
"firebase-admin": "^14",
|
|
15
15
|
"@naturalcycles/dev-lib": "18.4.2"
|
|
16
16
|
},
|
|
17
17
|
"exports": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=24.10.0"
|
|
40
40
|
},
|
|
41
|
-
"version": "2.
|
|
41
|
+
"version": "2.16.1",
|
|
42
42
|
"description": "Firestore implementation of CommonDB interface",
|
|
43
43
|
"author": "Natural Cycles Team",
|
|
44
44
|
"license": "MIT",
|
package/src/index.ts
CHANGED
package/src/query.util.ts
CHANGED
|
@@ -40,7 +40,11 @@ export function dbQueryToFirestoreQuery<ROW extends ObjectWithId>(
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// limit
|
|
43
|
-
|
|
43
|
+
// Careful here, Firestore just changed the behavior of limit(0) recently!
|
|
44
|
+
// Therefor we're guarding the limit(0) case and not sending the limit if it's zero.
|
|
45
|
+
if (dbQuery._limitValue) {
|
|
46
|
+
q = q.limit(dbQuery._limitValue)
|
|
47
|
+
}
|
|
44
48
|
|
|
45
49
|
// selectedFields
|
|
46
50
|
if (dbQuery._selectedFieldNames) {
|