Back

How to show user specific data?

  • 0
  • Databases
  • Flutter
new user
25 Apr, 2023, 05:29

Hi, how to show user specific data like in a collection we are storing all users data but how to fetch only users specific data, as i have tried this Query.equal("\$id", getuserId.$id), is there is any other way?

TL;DR
The user is asking how to show user-specific data in a collection. They suggest using the `Query.equal("\$id", getuserId.$id)` method, but they want to know if there is another way. The response suggests leveraging document-level read permissions or creating an additional `createdBy` attribute in the collection to save the creating user's ID. The response also provides a link to the documentation for more information.
Aditya Oberai
25 Apr, 2023, 08:33

One way to do it would be to leverage document-level read permissions so that you're setting each document to be viewed only by the user that creates the document.

Aditya Oberai
25 Apr, 2023, 08:33
Aditya Oberai
25 Apr, 2023, 08:36

The $id attribute in the collection would be the id of the document, not the user. So that query would not work.

If you want to leverage a query like that, you would to create an additional createdBy attribute and save the creating user's ID there.

That being said, the Permissions system is definitely a more secure way to achieve the same.

new user
25 Apr, 2023, 12:18

its sounds good, let me check the link.

new user
25 Apr, 2023, 12:30

this will be better approach ?Permission.delete(Role.user("getuserId.$id"))

new user
25 Apr, 2023, 12:39

i have one doubt, should we have to specify the role while creating the document because while fetching there is no optional parameter for specifying permission, am i right?

Bouahaza
25 Apr, 2023, 13:44

Yeah, permissions is define on create/update, not on fetch

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