You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How many can i get result with query.each ? (maximum size) #6248
Parse.Cloud.job('Purchase', (req,status) => {
var query = new Parse.Query('Subscriptions');
query.find({useMasterKey: true}).then(()=>{
query.each((result,err) => {
let userId = result.get('userId');
var _query = new Parse.Query(Parse.User);
_query.equalTo('objectId', userId);
_query.first({useMasterKey: true}).then((user => {
let date = result.get('end');
let current = new Date();
user.set('isGold', (date > current));
user.save(null,{useMasterKey: true});
}));
});
}).catch(e => console.log(e));
});
if I have more than 100,000 results in Subscriptions class, does it work for all result ? (query.limit(int) doesn't work with query.each, i tried.)
Your code is wrong. You are using the each function inside the find block. That's not the way it should be used. There is no limit for the each function if you use it correctly. It will do as many find operations are required to make sure that all objects will be returned.
@memishood thanks for reporting. The example is slightly different because they first used the find method to show how many objects will be destroyed. They should had used the count though and I will make sure they will update it. In your case, since you are not using the result of the find operation, you can go just with the each.
Activity
davimacedo commentedon Dec 2, 2019
Please, use stackoverflow for code related questions. Anyway, the code below should solve your problem:
memishood commentedon Dec 2, 2019
@davimacedo my code is working perfectly i just asked if the parse class have more than 100k row, will it work again perfectly?
davimacedo commentedon Dec 2, 2019
Your code is wrong. You are using the each function inside the find block. That's not the way it should be used. There is no limit for the each function if you use it correctly. It will do as many find operations are required to make sure that all objects will be returned.
memishood commentedon Dec 3, 2019
@davimacedo thx, i had got it from back4app docs :))) https://www.back4app.com/docs/free-cron-job-online
davimacedo commentedon Dec 3, 2019
@memishood thanks for reporting. The example is slightly different because they first used the
findmethod to show how many objects will be destroyed. They should had used thecountthough and I will make sure they will update it. In your case, since you are not using the result of thefindoperation, you can go just with theeach.memishood commentedon Dec 3, 2019
@davimacedo thx sir