Back

[CLOSED] Reference registered details in database

  • 0
  • Tools
  • Web
Jaydeep
25 May, 2023, 03:44

i am making a schema like this:

TypeScript
        title: String,
        description: String,
        image: String,
        members: [String],

        where members is an array of user ids
    }

is there any way to reference user in this schema based on collection of registered user

TL;DR
OP is asking about how to reference registered user details in a database. They mention creating a user collection and referencing it in another collection. However, it seems that manual referencing is necessary since array operations are not supported. The suggestion is to fetch the user list, update it locally, and then update the collection with the new list. It is also recommended to consider whether using an array for members is the best approach, as it can be problematic for simultaneous updates. The proposed schema includes an array of user IDs. It is unclear if there is a solution provided in the thread.
Drake
25 May, 2023, 03:47

No. When I use user details in my app, I typically create a collection of users. then, I can add any other attribute I need for the user.

Another suggestion I have is to really think about whether you want to use an array for members. Array operations are not supported so you'll need to do a full replace when adding a member. This can be problematic if you have multiple updates going on at the same time

Jaydeep
25 May, 2023, 03:50

so if i try to implement addition of members in my app, by pushing members in the array. I can't really do it right?

Drake
25 May, 2023, 03:51

You'd have to fetch the list, push locally, and then update with that full updated list

Jaydeep
25 May, 2023, 03:52

ok, lets say i create user collection, can i reference it in other collection?

Drake
25 May, 2023, 03:55

With the current version of cloud, it would be a manual reference. Appwrite 1.3 added support for relationships

Jaydeep
25 May, 2023, 03:56

Can you tell me about manual reference?

Jaydeep
25 May, 2023, 03:56

πŸ₯²

Drake
25 May, 2023, 04:24

Its just a string attribute where you put the ID

Jaydeep
25 May, 2023, 04:25

Ah okay

joeyouss
25 May, 2023, 08:02

[CLOSED] Reference registered details in database

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