Back

what to do to get other user data with its userid?

  • 1
  • Web
Sagar
1 Jan, 2024, 21:43

I want to fetch other user data using its userid but i can't achive it due to if i use account.get it will return current logged user to me what to do to get other user data with its userid.

TL;DR
User wants to fetch other user data using their user ID in a blogging website. The recommended method is to have a Function triggered on user data update. However, there is no direct way to access the private user table. One suggestion is to create a function to store all new user public data into a document and then access it using the user ID. Another suggestion is to create a Profiles collection for public visibility and use a function to populate and update the documents in that collection. The user wants to fetch other user data using their user ID but is unable to achieve this due to the limitations of the account.get method. One solution suggested is to
ideclon
1 Jan, 2024, 22:10

From a Client SDK you can’t get data of other users.

Sagar
1 Jan, 2024, 22:12

then where to get??

Sagar
1 Jan, 2024, 22:13

can u share resources to get through it

ideclon
1 Jan, 2024, 22:15

You could create a Function which uses the Server SDK to call the users.get() method. Just make sure you set correct permissions on the Function, and only return the fields you really need.

Sagar
1 Jan, 2024, 22:17

let me work on it.

Drake
1 Jan, 2024, 23:06

Why?

Sagar
1 Jan, 2024, 23:07

Actually I'm building a blogging website where I need this feature to fetch user details using its userid

Drake
1 Jan, 2024, 23:09

Why do you need to fetch user details?

Sagar
1 Jan, 2024, 23:13

I want that to user can view others profile 🤔

Drake
1 Jan, 2024, 23:19

The typical approach to this is to create a Profiles collection for what should be visible. The built in users is not publicly accessible because there's a lot of private data in there

Drake
1 Jan, 2024, 23:19

You can set up a function to automatically populate and update the documents in the profiles collection

Sagar
1 Jan, 2024, 23:21

Ohh should I create function which is store all new user public data into a document and then access it with I'd great suggestion thanks Steven

dieternuckelt
2 Jan, 2024, 00:23

But how do I get a foreign key reference to this private user table? Managing this using function seems really backwards.

ideclon
2 Jan, 2024, 00:31

That’s why I suggested a Function which only returns the required attributes

ideclon
2 Jan, 2024, 00:32

You’d set the Document ID to be the User ID, presumably

dieternuckelt
2 Jan, 2024, 01:23

But as I see it, there is no way to actually get a link to the private user table. So they would just share the user ID and not actually be in any relationship, thus not guaranteeing data integrity.

ideclon
2 Jan, 2024, 02:22

Well, my understanding is that the officially recommended method would be to have a Function triggered on user data update

Sagar
2 Jan, 2024, 05:55

Yeah, it cause but we dosen't have any other option now

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