-
Hi, I have been using this plugin for a bit now and have noticed there is no explicitly typed-out way to find out if a document exists in Firestore. However, I noticed that when a document does not exist, the response code is 404 in the _on_request_completed function. I was wondering if there was a way I could take this code and assert to return a value letting me know whether the document exists or not? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Error 404 is itself the way to know if a document exists or not.
If you actually want to only check the existence of a document without retrieving its data, there is no way I'm aware of. |
Beta Was this translation helpful? Give feedback.
Error 404 is itself the way to know if a document exists or not.
If a document does not exist on a .get() request, some signals will be emitted:
error(body_error : Dictionary)
andtask_finished(body_error : Dictionary)
from aFirestoreTask
error(body_error : Dictionary)
from aFirestore
Just connect those signals to a function, and if you get the error concerning a document it does not exist.
If you actually want to only check the existence of a document without retrieving its data, there is no way I'm aware of.
The only way would be to create a Document that stores the ids of all the other documents you are using, and then get the content of that document to check if an id exists.