Skip to content
Back

I want to consider that Org ID and email attribute should be unique

  • 0
  • Databases
Mosh Ontong
7 Dec, 2023, 08:46
TL;DR
It is important to have both the Org ID and email attribute be unique. If you create a unique index for both attributes, it will ensure that no two documents can have the same combination of Org ID and email. If you only have an index on the email attribute, the unique constraint will not apply as long as the Org IDs are different. To avoid any errors, create a unique index on both Org ID and email.
Drake
7 Dec, 2023, 12:07

Is this your custom collection?

Mosh Ontong
7 Dec, 2023, 12:07

yes

Drake
7 Dec, 2023, 12:08

If you want org Id to be unique, create a unique index on org Id. Same with email

Mosh Ontong
7 Dec, 2023, 12:09

so what if I have moshontong email on two document but the org ids is not the same does it still throws an error?

Ernest
7 Dec, 2023, 14:12

Since the org ids are different the unique constraint will not apply. Both documents will be regarded as distinct.

Drake
7 Dec, 2023, 17:29

This only applies if you create 1 unique index with both attributes.

If you have 1 index on email, no 2 document can have the same email

Ernest
7 Dec, 2023, 17:46

Yes, I'm aware of that ๐Ÿ‘

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