Back

[SOLVED] use Query to get document

  • 0
  • Self Hosted
Bill.IHCha
15 Jul, 2023, 05:25

for now I use listDocuments, but I only want to get 1 document, which would be easier to use getDocument with Query instead

TL;DR
The user wants to use a Query to get a document in the SDK. The solution is to use ListDocuments instead, as GetDocument does not support queries. The user suggests adding a new function called getDocumentByQuery.
Bill.IHCha
15 Jul, 2023, 05:25

is it even possible?

Drake
15 Jul, 2023, 05:25

GetDocument doesn't take queries 🧐

safwan
15 Jul, 2023, 05:26

It does in the docs πŸ˜…

Bill.IHCha
15 Jul, 2023, 05:26
Bill.IHCha
15 Jul, 2023, 05:26

ye that's what I'm wondering lol

Drake
15 Jul, 2023, 05:27

Weird...I can't see that...

Drake
15 Jul, 2023, 05:29

Ah, it was added in 1.3. read the description

Drake
15 Jul, 2023, 05:29

@Bill.IHCha :appwriteupvote:

Drake
15 Jul, 2023, 05:30

I meant read the description for what query method is supported

Bill.IHCha
15 Jul, 2023, 05:30

ah, only select?

Bill.IHCha
15 Jul, 2023, 05:32

it would be good to support getDocument with equal query tho?

Drake
15 Jul, 2023, 05:32

Why? It wouldn't really make sense...you're not trying to find a document with getDocument. You want the document with that ID

Bill.IHCha
15 Jul, 2023, 05:33

I have an attribute called user_id, which I want to just get it. which corresponding to discord user id

Drake
15 Jul, 2023, 05:34

You would use list documents then

Bill.IHCha
15 Jul, 2023, 05:35

I do, but I just feel it's better to use getDocument with query, if document doesn't exist it throws an AppwriteException. Right now I have to manually check if there is document.documents[0] everytime to handle all the errors, just doesn't feel right

Drake
15 Jul, 2023, 05:36

Get document is get document by id...

Drake
15 Jul, 2023, 05:36

It's not find one

Bill.IHCha
15 Jul, 2023, 05:36

maybe add new function called getDocumentByQuery?

Bill.IHCha
15 Jul, 2023, 05:36

or findDocument?

Bill.IHCha
15 Jul, 2023, 05:36

into the sdk

Bill.IHCha
15 Jul, 2023, 05:36

that would be great lol

Drake
15 Jul, 2023, 05:37

Feel free to create a feature request

Bill.IHCha
15 Jul, 2023, 05:37

alright

Bill.IHCha
15 Jul, 2023, 05:37

[SOLVED] use Query to get document

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