ParseServer object not found

152 views Asked by At

Parse.Query in cloud code cant find object

Running this code cloud function as a user who can reject or accept Invites. The code gets the invite (works) and checks for the given deckId, where the user should be added as a collaborator. But for some reason i can't explain the Query for the Deck always returns:

https://pastebin.com/XjLjvzXZ

I have checked: the docs for syntax -> should be fine the Invite object exists and has a deckId The Deck Objects exist and the deckId and Deck's objectId are matching

Parse.Cloud.define("inviteAction", async (request) => 
{
    const user = request.user;
    const inviteId =  request.params.invite;
    const action = request.params.actiom;
    let inviteQuery = new Parse.Query("Invite");
     const invite = await inviteQuery.get(inviteId, { useMasterKey: true } );
    if (invite != null && invite != undefined)
    {
        const deckId = invite.get("deckId");
        console.log(deckId);
        if (invite.get("invited") === user.getUsername()) 
        {
            if (action === "accept") 
            {
                let deckQuery = new Parse.Query("Deck");
                await deckQuery.get(deckId, { useMasterKey: true } ).then((deck) => 
                {
                    console.log(deck);
                    deck.addUnique("collaborators", user.getUsername());
                    deck.save();  
                }).catch((error) => 
                {
                    console.log(error);  // is always error
                });
            }
            invite.destroy();
            return true;
        }
    }
    return false;
});

This gives me the same error:

let deckQuery = new Parse.Query("Deck");
await deckQuery.find({ useMasterKey: true } ).then((deck) => 
{
    console.log(deck.length);
}).catch((error) => 
{
  console.log(error);
});
1

There are 1 answers

1
ILurch On

OMG im so dumb, apparently you get this error if you have a typo as well. I just changed

const action = request.params.actiom;

to

const action = request.params.action;