Skip to content

Commit ad10705

Browse files
committed
feat: add allowDiskUse as option/method
1 parent 5c14029 commit ad10705

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/ParseQuery.js

+23
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export type QueryJSON = {
4040
hint?: mixed,
4141
explain?: boolean,
4242
readPreference?: string,
43+
allowDiskUse?: Boolean,
4344
includeReadPreference?: string,
4445
subqueryReadPreference?: string,
4546
};
@@ -239,6 +240,7 @@ class ParseQuery {
239240
_count: boolean;
240241
_order: Array<string>;
241242
_readPreference: string;
243+
_allowDiskUse: boolean;
242244
_includeReadPreference: string;
243245
_subqueryReadPreference: string;
244246
_queriesLocalDatastore: boolean;
@@ -278,6 +280,7 @@ class ParseQuery {
278280
this._limit = -1; // negative limit is not sent in the server request
279281
this._skip = 0;
280282
this._readPreference = null;
283+
this._allowDiskUse = false;
281284
this._includeReadPreference = null;
282285
this._subqueryReadPreference = null;
283286
this._queriesLocalDatastore = false;
@@ -457,6 +460,9 @@ class ParseQuery {
457460
if (this._readPreference) {
458461
params.readPreference = this._readPreference;
459462
}
463+
if (typeof this._allowDiskUse === 'boolean') {
464+
params.allowDiskUse = this._allowDiskUse;
465+
}
460466
if (this._includeReadPreference) {
461467
params.includeReadPreference = this._includeReadPreference;
462468
}
@@ -534,6 +540,10 @@ class ParseQuery {
534540
this._readPreference = json.readPreference;
535541
}
536542

543+
if (typeof json.allowDiskUse === 'boolean') {
544+
this._allowDiskUse = json.allowDiskUse;
545+
}
546+
537547
if (json.includeReadPreference) {
538548
this._includeReadPreference = json.includeReadPreference;
539549
}
@@ -566,6 +576,7 @@ class ParseQuery {
566576
'subqueryReadPreference',
567577
'hint',
568578
'explain',
579+
'allowDiskUse',
569580
].indexOf(key) === -1
570581
) {
571582
this._extraOptions[key] = json[key];
@@ -840,6 +851,7 @@ class ParseQuery {
840851
hint: this._hint,
841852
explain: this._explain,
842853
readPreference: this._readPreference,
854+
allowDiskUse: this._allowDiskUse,
843855
};
844856
return controller.aggregate(this.className, params, aggregateOptions).then(results => {
845857
return results.results;
@@ -1955,6 +1967,17 @@ class ParseQuery {
19551967
return this;
19561968
}
19571969

1970+
/**
1971+
* Changes the allowDiskUse preference that the backend will use when performing the query to the database.
1972+
*
1973+
* @param {boolean} enabled enable/disable allowDiskUse
1974+
* @returns {Parse.Query} Returns the query, so you can chain this call.
1975+
*/
1976+
allowDiskUse(enabled: boolean): ParseQuery {
1977+
this._allowDiskUse = enabled;
1978+
return this;
1979+
}
1980+
19581981
/**
19591982
* Subscribe this query to get liveQuery updates
19601983
*

0 commit comments

Comments
 (0)