After a night of trial and error I have decided on a much simpler way to explain my issue. Again, I have no JS experience, so I don't really know what I am doing.
I have 5 classes:
- game - holds information about my games
- classification - holds information about the user classes available in games
- game_classifications - creates a one game to many classifications relationship (makes a game have mulitple classes)
- mission - holds my mission information
- mission_class - creates a one to many relationship between a mission and the classes available for that mission
Using Cloud Code, I want to provide two inputs through my Rest API being missionObjectId and gameObjectId.
The actual steps I need the code to perform are:
- Get the two inputs provided
{"missionObjectId":"VALUE","gameObjectId":"VALUE"} - Search the game_classifications class for all records where game = gameObjectID
- For each returned record, create a new record in mission_class with the following information:
-
- mission_id = missionObjectId
-
- classification = result.classification
Here is an image of the tables:

And here is how I have tried to achieve this:
Parse.Cloud.define("activateMission", async (request) => {
Parse.Cloud.useMasterKey();
const query = new Parse.query('game_classifications');
query.equalTo("gameObjectId", request.params.gameObjectId);
for (let i = 0; i < query.length; i ++) {
const mission_classification = Parse.Object.extend("mission_class");
const missionClass = new mission_classification();
missionClass.set("mission_id", request.params.missionObjectId);
missionClass.set("classification_id", query[i].classificationObjectId);
return missionClass.save();
}
});
Does anyone have any advice or input that might help me achieve this goal?
The current error I am getting is:
Parse.query is not a constructor
Thank you all in advance!
Some problems on your current code:
Parse.Cloud.useMasterKey()does not exist for quite a long time. UseuseMasterKeyoption instead.Parse.Queryand notParse.query.query.findAll()command and iterate over it (and not over query).Parse.Object.extendcalls to the beginning of the file.obj.get('fieldName')and notobj.fieldName.So, the code needs to be something like this: