Back

Unique index on 2 reference attributes

  • 0
  • Databases
  • Cloud
Said Hasyim
2 Apr, 2024, 06:40

Hello, I'm trying to set up a unique entry on a collection where 2 attributes must be unique.

Specifically, in this screenshot, i want to have the combination of word and users to be unique per entry. For example: Allowed: word: A, users: 1 Allowed: word: B, users: 1 Disallowed: word: A, users: 1. because the same value already being input earlier.

Sorry i can't find a way to do this. In index option, there is no option for reference. Any suggestion?

TL;DR
Developers want to create a unique index based on two reference attributes in a collection. They want to ensure that the combination of 'word' and 'users' is unique per entry. Unfortunately, there isn't an option for reference in the index settings. Solution: The developers can achieve this by creating a compound index on both 'word' and 'users' attributes. This will enforce uniqueness on the combination of those two fields.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more