Good evening everyone,
I ask for the help of the community because we are setting up a realm environment with partition sync and I would like to understand if it is possible to perform some operations automatically.
Our application foresees that a user can create documents in a collection called “sites” and that he can share these documents with other users.
as a partitioning system we have chosen to use a _partition field in the documents of the “sites” collection.
to share the “site” documents we have created two arrays in the custom data of each user: readPartitions and writePartitions which respectively contain the partitions that a user can read and read / write. For a user to be able to share a document with another user in read-only mode, he must launch a function that inserts the document partition in the readPartitions array of the user with whom he wants to share the document.
for each “site” document in the “sites” collection we used a string composed of the prefix “site_” and the objectId of the “site” document as the value of the _partition field. Eg:
{
...,
_partition: "site_76e68a7587387e8f7678"
}
what we would like to create is a trigger that is triggered when a “site” document is created and which automatically values the _partition field of the document just created and, at the same time, inserts the value of the partition in the writePartition array present in the custom data of the user who made the insertion.
it’s possible to do it?
thank you.