backend-manager 3.0.43 → 3.0.44
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
|
@@ -23,9 +23,12 @@ Utilities.prototype.iterateCollection = function (callback, options) {
|
|
|
23
23
|
options.orderBy = options.orderBy || null;
|
|
24
24
|
options.startAt = options.startAt || null;
|
|
25
25
|
options.startAfter = options.startAfter || null;
|
|
26
|
+
options.prefetchCursor = typeof options.prefetchCursor === 'undefined'
|
|
27
|
+
? (!!options.startAt || !!options.startAfter) && !options.orderBy
|
|
28
|
+
: options.prefetchCursor;
|
|
26
29
|
options.log = options.log;
|
|
27
30
|
|
|
28
|
-
function listAllDocuments(nextPageToken) {
|
|
31
|
+
async function listAllDocuments(nextPageToken) {
|
|
29
32
|
let query = admin.firestore().collection(options.collection)
|
|
30
33
|
|
|
31
34
|
options.where
|
|
@@ -37,12 +40,24 @@ Utilities.prototype.iterateCollection = function (callback, options) {
|
|
|
37
40
|
query = query.orderBy(options.orderBy);
|
|
38
41
|
}
|
|
39
42
|
|
|
40
|
-
if (batch === -1
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
if (batch === -1) {
|
|
44
|
+
let prefetchedCursor = null;
|
|
45
|
+
|
|
46
|
+
if (options.prefetchCursor) {
|
|
47
|
+
prefetchedCursor = await admin.firestore().doc(`${options.collection}/${options.startAt || options.startAfter}`)
|
|
48
|
+
.get()
|
|
49
|
+
.catch(e => e);
|
|
50
|
+
|
|
51
|
+
if (prefetchedCursor instanceof Error) {
|
|
52
|
+
return reject(prefetchedCursor);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
43
55
|
|
|
44
|
-
|
|
45
|
-
|
|
56
|
+
if (options.startAt) {
|
|
57
|
+
query = query.startAt(prefetchedCursor || options.startAt);
|
|
58
|
+
} else if (options.startAfter) {
|
|
59
|
+
query = query.startAfter(prefetchedCursor || options.startAfter);
|
|
60
|
+
}
|
|
46
61
|
}
|
|
47
62
|
|
|
48
63
|
// Start at next page
|