It is returning undefined but i can clearly see that the document exists in the collection with given id and deleted = false
Summary
Developers reported a bug regarding the `getDocument` function in the databases. One simple workaround is suggested to avoid the query feature in requests. The issue arises when using a query array parameter in `getDocument`. Some developers confirmed the bug and mentioned they are on version 1.5.6. Upgrading to the latest version 1.5.7 might solve the problem. Further discussion revealed that querying with a specific condition like `deleted: false` is causing the function to return `undefined`, even though the document exists with the given properties.
Solution: As a temporary fix, avoid using the query array parameter in the `
Vineet
Rank 2: Process
May 29, 2024, 09:10
Am i doing something wrong ?
Vineet
Rank 2: Process
May 29, 2024, 09:11
Just searching the id itself works and returns the proper document but querying with the bool is returning undefined
Meldiron
May 29, 2024, 09:12
Appwrite database is secure by default. All documents are invisible to internet. You can mark whole collection or specific document visible by going into it's settings and giving read permission to any.
Meldiron
May 29, 2024, 09:13
Vineet
Rank 2: Process
May 29, 2024, 09:15
I am running it locally on my machine and the read permission is set properly.
Vineet
Rank 2: Process
May 29, 2024, 09:15
The issue is only occuring when passing the above query
Meldiron
May 29, 2024, 09:16
Aaah. I see. So if you getDocument without queries array, you get the document in return. It's only when you add the query that it wont reutrn your document. Am I right?
Vineet
Rank 2: Process
May 29, 2024, 09:16
yes
Meldiron
May 29, 2024, 09:17
Thanks for confirming 🙏 Let me try to reproduce quickly
Meldiron
May 29, 2024, 09:17
Are you running latest Appwrite, 1.5.7?
Vineet
Rank 2: Process
May 29, 2024, 09:17
i am on 1.5.6
Meldiron
May 29, 2024, 09:20
Hmm I can confirm there seems to be a bug. cc @Jake
As seen on screenshots below, listDocuments work as expected, but getDocument doesnt.
Meldiron
May 29, 2024, 09:21
As a quick solution, you could avoid query feature in your request. For example,
JavaScript
let doc =await databases.getDocument(col.databaseId, col.id, id)
if(doc.deleted){
doc =null;
}
// Rest of your code
Vineet
Rank 2: Process
May 29, 2024, 09:23
hmm, that is what i am doing for now. Thanks for checking it out.
Meldiron
May 29, 2024, 09:23
Thanks for reporting this 🙏 We will work on a fix very soon.