Back

databases.get bug ?

  • 0
  • Web
Vineet
29 May, 2024, 09:09

I am not sure if this is a bug but whenever i try

const notDeletedQuery = Query.equal('deleted', false) databases.getDocument(col.databaseId, col.id, id, [notDeletedQuery])

It is returning undefined but i can clearly see that the document exists in the collection with given id and deleted = false

TL;DR
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
29 May, 2024, 09:10

Am i doing something wrong ?

Vineet
29 May, 2024, 09:11

Just searching the id itself works and returns the proper document but querying with the bool is returning undefined

Meldiron
29 May, 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
29 May, 2024, 09:13
Vineet
29 May, 2024, 09:15

I am running it locally on my machine and the read permission is set properly.

Vineet
29 May, 2024, 09:15

The issue is only occuring when passing the above query

Meldiron
29 May, 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
29 May, 2024, 09:16

yes

Meldiron
29 May, 2024, 09:17

Thanks for confirming πŸ™ Let me try to reproduce quickly

Meldiron
29 May, 2024, 09:17

Are you running latest Appwrite, 1.5.7?

Vineet
29 May, 2024, 09:17

i am on 1.5.6

Meldiron
29 May, 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
29 May, 2024, 09:21

As a quick solution, you could avoid query feature in your request. For example,

TypeScript
let doc = await databases.getDocument(col.databaseId, col.id, id)

if(doc.deleted) {
  doc = null;
}

// Rest of your code
Vineet
29 May, 2024, 09:23

hmm, that is what i am doing for now. Thanks for checking it out.

Meldiron
29 May, 2024, 09:23

Thanks for reporting this πŸ™ We will work on a fix very soon.

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