Reputation: 353
I am in a situation where I have to create a document if it didn't exist in a collection, or delete it if exists.
In order to solve this situation, I have thought to:
1. Read doc
2. If !doc.exists -> create it
3. Else -> delete it
But, maybe, it will be cheaper to do:
1. Try to create a doc.
2. If fails because it exists, delete it.
I have been looking the documentation https://firebase.google.com/docs/firestore/pricing but I don't find anything related to unseccesful operations. Will I be charged with a document creation if it fails?
Upvotes: 1
Views: 219
Reputation: 20081
The create
, though failed, is still counts as a write operation.
Unfortunately I am unable to provide steps to observe this behavior. The response is based on my own use of Firestore and seeing write counts increase with failed writes. It is not clear if all failure types will increase the write count or what the needed conditions are. Unfortunately this information is not available from GCP documentation.
Upvotes: 1