Last active
July 6, 2023 15:15
-
-
Save alexb4a/a1335c3e714c99827528d3d9a93fee7d to your computer and use it in GitHub Desktop.
A very INEFFICIENT way to retrieve all Employees.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This Cloud Code Function returns all objects from Person that have the isEmployee property set to True | |
Parse.Cloud.define("getEmployees", async (request) => { | |
const Person = Parse.Object.extend("Person"); // Instantiates the Person Class | |
const query = new Parse.Query(Person); // Instantiates a new Query for the Person Class | |
const tempArray = await query.find(); // Retrieves all Person objects | |
let finalArray = []; // Creates an empty array to store results | |
// Loops through the results retreived by the Query | |
for (let i = 0; i < tempArray.length; i++){ | |
// If isEmployee property is true | |
if (tempArray[i].get("isEmployee")){ | |
// Pushes the object to the final Array | |
finalArray.push(tempArray[i]); | |
} | |
} | |
// Returns the final array | |
return finalArray; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment