Hi! Is it possible to set a unique index per user on one field? I could store another field with the user ID and create a unique index over both fields. But this is not so nice because in this case document security is enabled so the user is known anyway.
Summary
The user is asking if it is possible to set a unique index per user on one field in a collection called "fruits". The user wants each user to be able to enter their favorite fruit, but the name of the fruit must be unique for each user. They suggest creating a unique index that includes both the user ID and fruit attributes. The user is aware that they could store another field with the user ID and create a unique index over both fields, but they find this solution less ideal. There is no solution provided in the thread.
Drake
Admin
Apr 15, 2023, 17:14
Sorry I'm not quite sure what you mean. What are you trying to do? Make sure no 2 documents have the same value?
zwelch
Rank 1: Thread
Apr 15, 2023, 17:24
Let's assume there is a collection "fruits". Every logged in user can deposit his favorite fruits. Each name of a fruit must be unique (apple, banana, pineapple). Therefore a unique index. But another user can also have "banana" as favorite fruit and should be able to enter it. Therefore I need a unique index for one column per user.
Drake
Admin
Apr 15, 2023, 17:30
This should be possible with 1 unique index that has both the user id and fruit attributes