backend-manager 4.0.15 → 4.0.16
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/package.json
CHANGED
|
@@ -27,6 +27,7 @@ Utilities.prototype.iterateCollection = function (callback, options) {
|
|
|
27
27
|
// Set counters
|
|
28
28
|
let batch = -1;
|
|
29
29
|
let collectionCount = 0;
|
|
30
|
+
let callbackResults = [];
|
|
30
31
|
|
|
31
32
|
// Set defaults
|
|
32
33
|
options = options || {};
|
|
@@ -116,7 +117,7 @@ Utilities.prototype.iterateCollection = function (callback, options) {
|
|
|
116
117
|
|
|
117
118
|
// If no documents, resolve
|
|
118
119
|
if (snap.docs.length === 0) {
|
|
119
|
-
return resolve();
|
|
120
|
+
return resolve(callbackResults);
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
// Log
|
|
@@ -134,11 +135,14 @@ Utilities.prototype.iterateCollection = function (callback, options) {
|
|
|
134
135
|
collectionCount,
|
|
135
136
|
)
|
|
136
137
|
.then((r) => {
|
|
138
|
+
// Append to result
|
|
139
|
+
callbackResults.push(r);
|
|
140
|
+
|
|
137
141
|
// Construct a new query starting at this document (unless we've reached the end)
|
|
138
142
|
if (lastVisible && batch + 1 < options.maxBatches) {
|
|
139
143
|
iterate(lastVisible)
|
|
140
144
|
} else {
|
|
141
|
-
return resolve();
|
|
145
|
+
return resolve(callbackResults);
|
|
142
146
|
}
|
|
143
147
|
})
|
|
144
148
|
.catch((e) => {
|
|
@@ -180,6 +184,7 @@ Utilities.prototype.iterateUsers = function (callback, options) {
|
|
|
180
184
|
|
|
181
185
|
// Set counters
|
|
182
186
|
let batch = -1;
|
|
187
|
+
let callbackResults = [];
|
|
183
188
|
|
|
184
189
|
// Set defaults
|
|
185
190
|
options = options || {};
|
|
@@ -199,7 +204,7 @@ Utilities.prototype.iterateUsers = function (callback, options) {
|
|
|
199
204
|
|
|
200
205
|
// If no users, resolve
|
|
201
206
|
if (listUsersResult.users.length === 0) {
|
|
202
|
-
return resolve();
|
|
207
|
+
return resolve(callbackResults);
|
|
203
208
|
}
|
|
204
209
|
|
|
205
210
|
// Log
|
|
@@ -213,12 +218,15 @@ Utilities.prototype.iterateUsers = function (callback, options) {
|
|
|
213
218
|
users: listUsersResult.users,
|
|
214
219
|
pageToken: listUsersResult.pageToken,
|
|
215
220
|
}, batch)
|
|
216
|
-
.then(r => {
|
|
221
|
+
.then((r) => {
|
|
222
|
+
// Append to result
|
|
223
|
+
callbackResults.push(r);
|
|
224
|
+
|
|
217
225
|
// Construct a new query starting at this document (unless we've reached the end)
|
|
218
226
|
if (listUsersResult.pageToken && batch + 1 < options.maxBatches) {
|
|
219
227
|
iterate(listUsersResult.pageToken);
|
|
220
228
|
} else {
|
|
221
|
-
return resolve();
|
|
229
|
+
return resolve(callbackResults);
|
|
222
230
|
}
|
|
223
231
|
})
|
|
224
232
|
.catch((e) => {
|
|
@@ -279,7 +287,7 @@ Utilities.prototype.getDocumentWithOwnerUser = function (path, options) {
|
|
|
279
287
|
// Get document
|
|
280
288
|
const document = await admin.firestore().doc(path)
|
|
281
289
|
.get()
|
|
282
|
-
.then(doc => {
|
|
290
|
+
.then((doc) => {
|
|
283
291
|
const data = doc.data();
|
|
284
292
|
|
|
285
293
|
// If the document doesn't exist, throw an error
|
|
@@ -308,7 +316,7 @@ Utilities.prototype.getDocumentWithOwnerUser = function (path, options) {
|
|
|
308
316
|
// Get the owner user
|
|
309
317
|
const user = admin.firestore().doc(`users/${ownerUID}`)
|
|
310
318
|
.get()
|
|
311
|
-
.then(doc => {
|
|
319
|
+
.then((doc) => {
|
|
312
320
|
const data = doc.data();
|
|
313
321
|
|
|
314
322
|
// If the user doesn't exist, throw an error
|