I'm struggling to figure out why my queries will not work when called from Parse.Cloud triggers.
I want to define some logic after an object of particular class was saved (the class is 'Message' in my case).
I'm testing the following simple code in my cloud/main.js:
const conversationQuery = new Parse.Query('Conversation');
conversationQuery.get('myIdHere', { useMasterKey: true })
.then(conversation => {
console.log('### Conversation is', conversation);
})
.catch(err => {
console.log('### Error is', err);
});
Parse.Cloud.afterSave('Message', req => {
const conversationQuery1 = new Parse.Query('Conversation');
conversationQuery1.get('myIdHere', { useMasterKey: true })
.then(conversation => {
console.log('>>> Conversation is', conversation);
})
.catch(err => {
console.log('>>> Error is', err);
});
});
And when I start my instance of parse-server, the following is logged to the console:
### Conversation is { myObjectHere }
However, when I save any object of 'Message' class, I get an error:
>>> Error is { Error: Object not found. <stacktrace here>, message: 'Object not found.', code: 101 }
I'd expect it to log the very same object that was retreived when the server started but instead, it returns a '101 object not found' error.
I think I configured everything according to the documentation but there's a possibility I just missed something.
I'm using Parse Server 3.1.3 and Parse JS SDK 2.1.0
afterSavetrigger forConversationclass onParseServerA, calls the query for class inParseServerB. I.e. the server A is under/serverA/URL and B under/serverB/but the trigger defined on server A callsurl=/serverB/classes/Conversationin a GET request. Kinda weird.Parse.initializeneither inindex.jsnorcloud/main.jsfiles. Also, the cloud code is passed to only one Parse instance, the one of Server B does not have any cloud code. I will dig into this a bit more and open an appropriate ticket on GitHub. For now I run only one instance of Parse Server and it works flawlessly.