Skip to content

beforeFind always returns master: false  #4679

Closed
@khalilsarabey

Description

@khalilsarabey

Hello!

I'm using beforeFind on a Message class to filter messages according to conversations and everything is working well.
However, in some cases, I want to bypass this filter, specifically when a conversation is deleted, so what I'm doing is I'm running find on Message class and I'm using the master key in order to destroy all those messages, however, beforeFind is always returning master as false.

Here is the actual code in beforeFind:

     let isMaster = request.master;    

     if(!isMaster) {
        if(!request.user) {
            throw new Parse.Error("You are not logged in, please log in");
        }
        let jsonQuery = request.query.toJSON();
        if(jsonQuery.where.inbox) {
            let inbox = new Parse.Query('Inbox');
            inbox.get(jsonQuery.where.inbox.objectId).then(function(results) {
                request.query.matchesQuery('inbox', results);
            });
        }
    }

And the query I'm running is:

        let message = new Parse.Query('Message');
        message.equalTo('inbox', request.object);
        return message.find(null, {useMasterKey: true});

The result in the debugger is this:

parse-app > { triggerName: 'beforeFind',
parse-app >   query:
parse-app >    ParseQuery {
parse-app >      className: 'Message',
parse-app >      _where: { inbox: [Object] },
parse-app >      _include: [],
parse-app >      _limit: 100,
parse-app >      _skip: 0,
parse-app >      _extraOptions: {} },
parse-app >   master: false,
parse-app >   count: false,

Maybe this is a bug? or am I missing something?
According to the documentation this should work ...

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions