0

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

5
  • Yeah, should work, right? You should turn on verbose logging and look carefully at the requests being made and you should be able to see the mistake. If not, post them here (appropriately redacted of course) and I'll take a look. Commented Jan 15, 2019 at 1:56
  • How can I enable verbose logging? I looked at the logs in Parse Dashboard but they do not say more than 'object not found'. Commented Jan 15, 2019 at 21:34
  • @ArthurCinader, thanks, I can see now! I have a few instances of Parse Server running and somehow my afterSave trigger for Conversation class on ParseServer A, calls the query for class in ParseServer B. I.e. the server A is under /serverA/ URL and B under /serverB/ but the trigger defined on server A calls url=/serverB/classes/Conversation in a GET request. Kinda weird. Commented Jan 15, 2019 at 22:36
  • By any chance did you reset or call Parse.initialize anywhere in your cloud code? Commented Jan 16, 2019 at 0:36
  • @flovilmart, no, I do not call Parse.initialize neither in index.js nor cloud/main.js files. 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. Commented Jan 18, 2019 at 19:35

1 Answer 1

1

https://github.com/parse-community/parse-server#logging it depends on how you start your parse server, but generally something like: VERBOSE="1" parse-server

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.