#community-help

Adding and Filtering Multiple IDs to a 'permissions' Field

TLDR Sean sought advice on restricting document access by adding multiple numeric IDs to a 'permissions' field. Sandip confirmed it was possible and provided a search request example.

Powered by Struct AI
4
1mo
Solved
Join the chat
Aug 29, 2023 (1 month ago)
Sean
Photo of md5-cd6101523d59f9331291c2b25acbceac
Sean
05:25 PM
I’m looking at a way to restrict documents from a collection to specific users in my app.
Is it possible to add multiple numeric ID’s to a field?

Thinking something like a field called ‘permissions’ which can have multiple ID’s, i.e, [123, 124, 125]. Then in the users search, we can add their ID to the filterBy parameter i.e. filterBy: 124, so that we only get results where there ID is included?
Sandip
Photo of md5-15d14f788c619474a46b8fb0c08210bb
Sandip
05:36 PM
Yup, it is possible.
search request should be
filter_by:permissions:=124
Sean
Photo of md5-cd6101523d59f9331291c2b25acbceac
Sean
05:38 PM
Great, actually, just seen in the docs that I can add an array of integers too. perfect!
Sandip
Photo of md5-15d14f788c619474a46b8fb0c08210bb
Sandip
05:38 PM
👍