2

I have a cloud function running some code like this and I am able to get a response for my query which is a valid class instance, but when I try to update the instance with the set method, I get the error you see in the title.

async function addToDB(apiKey) {
    const query = new Parse.Query(MyClass);
    query.equalTo('apiKey', apiKey);
    const response = await query.find({ useMasterKey: true });
    const myInstance = response[0];
    myInstance.set('total', 100);
    try {
        await myInstance.save({ useMasterKey: true });
    } catch (e) {
        console.log('E', e);
    }
}
3
  • Could you add console.log(myInstance) below const myInstance = response[0]; line and update the post with the results? I would like to have better insight on the contents. I found a similar issue due to class level/object level permissions on this post. Commented Jul 13, 2018 at 13:56
  • ParseObjectSubclass { className: 'MyClass', _objCount: 0, id: 'GstyehLqIN' } Commented Jul 14, 2018 at 23:43
  • 1
    I'm not sure where are you running this. At first I thought you were using Google Cloud Functions but after investigating I think you are running this in Parse-Server, could you confirm? Either way, I found this question that may be of help, a solution was found in there. As @RubénC pointed out with the post he sent, it's probably a ACL problem. Also, here's the guide for Parse queries. Commented Jul 18, 2018 at 16:00

1 Answer 1

8

the options parameter ( { useMasterKey : true}) should be the second parameter passed to save

the first parameter to a save should be a null, i.e. :

myInstance.save(null, { useMasterKey: true })

in essence, you are not passing the masterkey option in to the save call - which is why you are getting the 101 error (in my experience, a 101 is almost always related to permissions issues!)

see more here http://parseplatform.org/Parse-SDK-JS/api/v1.11.1/Parse.Object.html#save

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.