Moralis queries - bypassing permissions for included resources

Hello there :wave:

I’m trying to fetch all projects including their creator with a single query in a cloud function. The creator is a User type object and I cannot seem to fetch any user other than the logged in one. I’ve read that I need to use {useMasterKey:true} when fetching the data, but have only seen it used as a parameter to find() . I tried adding in inside include as well but it does not seem to work.

This is what I’ve attempted:

Moralis.Cloud.define("getProjectsWithCreator", (request) => {
    const query = new Moralis.Query("Project");
    query.include("user", {useMasterKey:true});
    return query.find({useMasterKey:true})

I’d appreciate your help

you don’t need to add that master key parameter to .include, only to .find

Indeed, but unfortunately it didn’t work either way.

what is the code that use use now?

the one in the description

that code still uses master key in two places

Thanks, changed the code - the problem was in the database - the owner object was undefined due to some triggers.