Join collections to limit access to entries #1690
-
|
Hi there First of all thank you for your awesome product, I really enjoyed exploring it so far :-) In my app, there are users and groups (many to many). I want to limit access to users to those, who you are already in a group together with the logged in user. I would have imagined something like this for a list/search rule: What I'm trying to say is give me all users there the memberIds-Array of a group contains the id of the user and the id of the logged-in user. Sidenote: You can still add a "new" user if you type the exact email adress, which I do using a request param, so there will be a "|| email = @request.query.email" in the filter, but that is working fine. I could of course add a collection reference to groups on the user (this would be my solution for now), but then I need to keep that in sync. Unless pocketbase provides me with an inverse relation? Furthermore, I want to limit the response to only users that are currently not in the group yet, so I'm doing Is there a more elegant way for this, for example: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
The example is too abstract and I'm not sure that I understand the described data structure and expected workflow. There are several ways you can handle relations in PocketBase - direct single or multi- Could you provide more information on your collections and relation fields structure (you can export your collections configuration as json from the "Admin UI > Settings > Export collections")? With v0.11+ there is now support for multi-match/match-all conditions that are the defaults when dealing with multi-value fields. If
No, there is no other way at the moment and if you want to combine multiple conditions you'll have to use |
Beta Was this translation helpful? Give feedback.
The example is too abstract and I'm not sure that I understand the described data structure and expected workflow.
There are several ways you can handle relations in PocketBase - direct single or multi-
relationfield(s), junction collection(s) or combination of both.Could you provide more information on your collections and relation fields structure (you can export your collections configuration as json from the "Admin UI > Settings > Export collections")?
With v0.11+ there is now support for multi-match/match-all conditions that are the defaults when dealing with multi-value fields. If
memberIdsin the above is arelationfield (it may be better to name it justmembers), then you can do…