简体   繁体   中英

Parse: ParseError { code: 101, message: 'Object not found.' }

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);
    }
}

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

the first parameter to a save should be a null , ie :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM