Ensure all roles are properly loaded #5131 (#5132)

* Fix Limitation Role #5131

Allow to manage Live Query with User that have more than 100 Parse.Roles

* Clean Up

* Add Custom Config Support and Test

* Fix Auth Test

* Switch to Async Function

* Fix restWhere

* Fix Test

* Clean Final Commit

* Lint Fix

* Need to Fix Test Callback

* Fixes broken test

* Restore find() method in spy

* adds restquery-each

* small nit

* adds changelog
This commit is contained in:
Antoine Cormouls
2018-10-20 22:45:23 +02:00
committed by Florent Vilmart
parent aa9580e59c
commit de79b70cbc
6 changed files with 157 additions and 34 deletions

View File

@@ -4,7 +4,7 @@
var SchemaController = require('./Controllers/SchemaController');
var Parse = require('parse/node').Parse;
const triggers = require('./triggers');
const { continueWhile } = require('parse/lib/node/promiseUtils');
const AlwaysSelectedKeys = ['objectId', 'createdAt', 'updatedAt', 'ACL'];
// restOptions can include:
// skip
@@ -199,6 +199,36 @@ RestQuery.prototype.execute = function(executeOptions) {
});
};
RestQuery.prototype.each = function(callback) {
const { config, auth, className, restWhere, restOptions, clientSDK } = this;
// if the limit is set, use it
restOptions.limit = restOptions.limit || 100;
restOptions.order = 'objectId';
let finished = false;
return continueWhile(
() => {
return !finished;
},
async () => {
const query = new RestQuery(
config,
auth,
className,
restWhere,
restOptions,
clientSDK
);
const { results } = await query.execute();
results.forEach(callback);
finished = results.length < restOptions.limit;
if (!finished) {
restWhere.objectId = { $gt: results[results.length - 1].objectId };
}
}
);
};
RestQuery.prototype.buildRestWhere = function() {
return Promise.resolve()
.then(() => {