Skip to content
Back

exclude password field from getDocument

  • 0
  • Databases
  • Web
kakadu222
4 May, 2025, 15:19

i got a getDocument that lists data from the user (username, password, id.....)

so my question is how do i exclude the password so it doesnt get listed out?

my code:

TypeScript
const result = await database.getDocument(
    DATABASE_ID,
    USERS_COLLECTION_ID,
    userId.documents[0].$id
);
TL;DR
Developers are concerned about having the password field in the response from the getDocument query and want to exclude it. To do this, use the Query.select method and specify the attributes you want to fetch, such as "name" and "title" in this case. By doing so, the password field can be omitted from the response.
kakadu222
4 May, 2025, 15:22

ps. the response in the console:

TypeScript
{
  username: 'BBBB BBBB',
  password: 'x',
  '$id': '32923',
  '$createdAt': '2025-05-03T15:26:53.449+00:00',
  '$updatedAt': '2025-05-03T15:26:53.449+00:00',
  '$permissions': [],
  '$databaseId': '680a2e8b002c2db36574',
  '$collectionId': '680a2ec200001dd95365'
}

i dont want to have the password in response

Axistro
4 May, 2025, 15:53

Use Query.select Add the attribute you want to fetch

Axistro
4 May, 2025, 15:54

Query.select(["name", "title"]) You would have to use list document i guess.....

Axistro
4 May, 2025, 15:55

Btw Having password in the collection. Are you sure its ok? Why not use the auth?

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