@naturalcycles/firestore-lib 2.3.0 → 2.4.0

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.
@@ -88,19 +88,19 @@ export class FirestoreDB extends BaseCommonDB {
88
88
  const method = methodMap[opt.saveMethod] || 'set';
89
89
  if (opt.tx) {
90
90
  const { tx } = opt.tx;
91
- rows.forEach(row => {
91
+ for (const row of rows) {
92
92
  _assert(row.id, `firestore-db doesn't support id auto-generation, but empty id was provided in saveBatch`);
93
93
  tx[method](col.doc(escapeDocId(row.id)), _filterUndefinedValues(row));
94
- });
94
+ }
95
95
  return;
96
96
  }
97
97
  // Firestore allows max 500 items in one batch
98
98
  await pMap(_chunk(rows, 500), async (chunk) => {
99
99
  const batch = firestore.batch();
100
- chunk.forEach(row => {
100
+ for (const row of chunk) {
101
101
  _assert(row.id, `firestore-db doesn't support id auto-generation, but empty id was provided in saveBatch`);
102
102
  batch[method](col.doc(escapeDocId(row.id)), _filterUndefinedValues(row));
103
- });
103
+ }
104
104
  await batch.commit();
105
105
  }, { concurrency: 1 });
106
106
  }
@@ -123,16 +123,16 @@ export class FirestoreDB extends BaseCommonDB {
123
123
  const col = firestore.collection(table);
124
124
  if (opt.tx) {
125
125
  const { tx } = opt.tx;
126
- ids.forEach(id => {
126
+ for (const id of ids) {
127
127
  tx.delete(col.doc(escapeDocId(id)));
128
- });
128
+ }
129
129
  return ids.length;
130
130
  }
131
131
  await pMap(_chunk(ids, 500), async (chunk) => {
132
132
  const batch = firestore.batch();
133
- chunk.forEach(id => {
133
+ for (const id of chunk) {
134
134
  batch.delete(col.doc(escapeDocId(id)));
135
- });
135
+ }
136
136
  await batch.commit();
137
137
  });
138
138
  return ids.length;
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "@types/node": "^24",
13
13
  "dotenv": "^17",
14
14
  "firebase-admin": "^13",
15
- "@naturalcycles/dev-lib": "19.11.0"
15
+ "@naturalcycles/dev-lib": "18.4.2"
16
16
  },
17
17
  "exports": {
18
18
  ".": "./dist/index.js"
@@ -38,7 +38,7 @@
38
38
  "engines": {
39
39
  "node": ">=22.12.0"
40
40
  },
41
- "version": "2.3.0",
41
+ "version": "2.4.0",
42
42
  "description": "Firestore implementation of CommonDB interface",
43
43
  "author": "Natural Cycles Team",
44
44
  "license": "MIT",
@@ -159,14 +159,14 @@ export class FirestoreDB extends BaseCommonDB implements CommonDB {
159
159
  if (opt.tx) {
160
160
  const { tx } = opt.tx as FirestoreDBTransaction
161
161
 
162
- rows.forEach(row => {
162
+ for (const row of rows) {
163
163
  _assert(
164
164
  row.id,
165
165
  `firestore-db doesn't support id auto-generation, but empty id was provided in saveBatch`,
166
166
  )
167
167
 
168
168
  tx[method as 'set' | 'create'](col.doc(escapeDocId(row.id)), _filterUndefinedValues(row))
169
- })
169
+ }
170
170
  return
171
171
  }
172
172
 
@@ -176,7 +176,7 @@ export class FirestoreDB extends BaseCommonDB implements CommonDB {
176
176
  async chunk => {
177
177
  const batch = firestore.batch()
178
178
 
179
- chunk.forEach(row => {
179
+ for (const row of chunk) {
180
180
  _assert(
181
181
  row.id,
182
182
  `firestore-db doesn't support id auto-generation, but empty id was provided in saveBatch`,
@@ -185,7 +185,7 @@ export class FirestoreDB extends BaseCommonDB implements CommonDB {
185
185
  col.doc(escapeDocId(row.id)),
186
186
  _filterUndefinedValues(row),
187
187
  )
188
- })
188
+ }
189
189
 
190
190
  await batch.commit()
191
191
  },
@@ -227,18 +227,18 @@ export class FirestoreDB extends BaseCommonDB implements CommonDB {
227
227
  if (opt.tx) {
228
228
  const { tx } = opt.tx as FirestoreDBTransaction
229
229
 
230
- ids.forEach(id => {
230
+ for (const id of ids) {
231
231
  tx.delete(col.doc(escapeDocId(id)))
232
- })
232
+ }
233
233
  return ids.length
234
234
  }
235
235
 
236
236
  await pMap(_chunk(ids, 500), async chunk => {
237
237
  const batch = firestore.batch()
238
238
 
239
- chunk.forEach(id => {
239
+ for (const id of chunk) {
240
240
  batch.delete(col.doc(escapeDocId(id)))
241
- })
241
+ }
242
242
 
243
243
  await batch.commit()
244
244
  })