How to add permission pointer for pointers in array field?

Viewed 143

In a table called Project, I have a column "users" that is a n-n relation with the User table. I want to give every user that is related, permission to read and update its own project object. Unfortunately I can't make this work via the following code:

const projectACL: Parse.Schema.CLP = {
  readUserFields: ["users"],
  writeUserFields: ["users"]
  }
};

The following error is thrown:

ParseError: 'users' is not a valid column for class level pointer permissions readUserFields

In the source code one can see there is a check if the argument of readUserFields and writeUserFields is a pointer OR an array, but "users" is a relation (not an array).

Is what I want even possible? I'm sorry I couldn't find any documentation or examples on this, so I would much appreciate an example of how to make it work.

2 Answers

I think you misunderstood the source code: it checks if the value is an array of column names, and if each listed column contains pointers to users, which is what you call a relation with the user table. So normally it should work if the users field is set like this, with user being an instance of Parse.User:

project.set('users', user);

The code which checks the fields is there and we can see an implementation example there.

I think you should use useMasterKey

 return user.save(null, {
    useMasterKey: true
  })
Related