Closed
Description
When I ran the following cloud code on parse-server I recieved the id of the first element twice ["VYSPEFBSx4", "VYSPEFBSx4"]
var data = ['7495176386', '8042291309'];
var query = new Parse.Query("Tick");
var results = [];
data.forEach(function(num){
query.equalTo("tickID", num);
query.first().then(function(result){
results.push(result.id);
});
});
The response should be ["VYSPEFBSx4", "EBLarI2NA1"] however it appears that the parse query was not overwritten for the second element in the loop. (This error did NOT occur on Parse.)
I finally found the solution which is to declare the parse query in the forEach loop like:
var data = ['8042291309','7495176386'];
var results = [];
data.forEach(function(num){
var query = new Parse.Query("Tick");
query.equalTo("tickID", num);
query.first().then(function(result){
results.push(result.id);
});
});
I did not see any mention of this error in the migration guide and thought it might be helpful
Metadata
Metadata
Assignees
Labels
No labels