Is there a way to create an API rule that only allows the user to create a record if there isn't already one with the same combination of values. I want it to be possible to have a record with the values "a" and "b" and also one with the values "a" and "c" but not another one with the values "a" and "b".
I tried to do something like
NOT IN (SELECT ... FROM table WHERE value_1="a")
The most straightforward way seems to be to create a new index on those columns in the edit collection form and check the "Unique" toggle in the new index form.
TL;DR
Click on the collection you want to edit:

Select "New Index" under unique constraints and indexes. In the New/Update Index Modal, you can toggle "Unique" and select from a list of presets (columns) to add them to the index.

See this comment from ganigeorgiev on github: https://github.com/pocketbase/pocketbase/issues/544#issuecomment-1477895278-permalink
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With