Relational pointer object is "undefined"

Here’s my scenario. I created a new “Project” class with a relational pointer to “_User” by doing something like this.

const { isInitialized, user, isAuthenticated, Moralis } = useMoralis();

const saveProject = () => {
    if (!validateForm()) return;

    setIsLoading(true);
    const Projects = Moralis.Object.extend("Projects");
    const project = new Projects();

    project.set("creator", user);
    project.set("team", [user.attributes.ethAddress]);
    project.set("projectName", projectName);
    project.set("projectDescription", projectDescription);

    project.save().then(
      () => {
        setIsLoading(false);
      },
      (error) => {
        setIsLoading(false);
      }
    );
  };

When signed in as the creator, everywhere else in the dapp I fetch for project and call

project.get("creator").attributes.ethAddress

It works perfectly. However, when signed in as a different user with a different wallet address. Calling the above gets undefined.

I suspect this is perhaps some defaulted read permissions on the “_User” class.

Looks like this is it
https://docs.moralis.io/moralis-dapp/database/queries#using-master-key

2 Likes