Back

[SOLVED] List documents of a user as admin

  • 0
  • Self Hosted
  • Web
BloodThermic
17 May, 2023, 04:51

I am wanting to list the documents of a specific user from an admin panel. What would I need to do. I dont want to need to login as a user to see the documents they have perms to see.

TL;DR
To list the documents of a specific user from an admin panel without needing to log in as that user, you can follow these steps: 1. Get a list of all documents in your database. 2. Filter the documents based on the user's ID. 3. Display the filtered list of documents in the admin panel. To achieve this, you can create a cloud function using the Appwrite API. Use the `listDocuments` method to retrieve all the documents and then filter them based on the user's ID. The exact implementation will depend on your specific database structure. Here is an example of how you can use the Appwrite API in
safwan
17 May, 2023, 05:15

What's your DB structure like? How would you know what document belongs to what user?

safwan
17 May, 2023, 05:17

You can create a cloud function that get's all the documents, and separates them based on the user.

https://appwrite.io/docs/server/databases?sdk=nodejs-default#databasesListDocuments

BloodThermic
17 May, 2023, 05:34

They way I have done it is give the user perms on the document

BloodThermic
17 May, 2023, 05:36

Should I change it to submitting an the id of the user who crated the document?

safwan
17 May, 2023, 05:45

That's what I do, yes.

BloodThermic
17 May, 2023, 05:47

Then I would just search for the id correct?

safwan
17 May, 2023, 05:56

yes. you would list all documents, and then filter them based on id

BloodThermic
18 May, 2023, 01:51

[SOLVED] List documents of a user as admin

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