So I have two tables:
const Org = a
.model({
orgId: a.id().required()
users: a.hasMany('User', 'OrgId')
})
.identifier(['orgId'])
.authorization((allow) => [
allow...
])
const User = a
.model({
userId: a.id().required()
users: a.belongsTo('Org', 'orgId')
})
.identifier(['userId'])
.authorization((allow) => [
allow.ownerDefinedIn('userId').to(['read'])
])
So the idea is that the org contains details associated with that org and then each org has many users that can access the org's data.
The problem is, I'm not sure how to handle this in an elegant way. Ideally, the owners would just be defined by the userIds of all the user entries that are attached to the Org but I'm not sure how to do that automatically... The closest I can see is the ownersDefinedIn() method, but that requires me to add userIds manually to the generated owners array? Which seems like a hacky way of doing it.
Any thoughts?