Back

Unique Id in string array

  • 0
  • Users
  • Flutter
  • Databases
Ansh
16 Sep, 2023, 11:11

i am storing a no. of Uids in an array string inside one of my collections. how can i make sure that no ids are repeated in that array i.e all the ids in that array are unique

TL;DR
The user wants to ensure that there are no repeated IDs in a string array stored in a collection. Suggestions include checking manually if the array is not too big, using the document ID for faster access, creating multiple documents with the desired attributes, and creating a unique index on the attributes. It is also suggested to create a separate collection for storing the IDs. TL;DR: User asks how to ensure unique IDs in a string array. Suggestions include manual checking, using the document ID, creating multiple documents or a separate collection, and creating a unique index.
Infinil
16 Sep, 2023, 12:30

u cant.. best way is to check inside your code.

Infinil
16 Sep, 2023, 12:31

or i will suggest making a separate collection 🤔

Infinil
16 Sep, 2023, 12:31

like there can be two attributes "main_doc_id" and "relation_doc_id"

Infinil
16 Sep, 2023, 12:32

and then you can create an unique index on those two attributes combined

Infinil
16 Sep, 2023, 12:32

afterwards u just have to create multiple documents with those attributes and your "relation_doc_id" attribute will take the id one by one from array you talked about

Infinil
16 Sep, 2023, 12:32

getting me?

darShan
16 Sep, 2023, 13:05

If the length of the array isn't too big, you can check manually firsthand. You should know the doc Id though for fast path access.

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