2

I can specify the source If I want to get data from firestore, either default, from server or from cache like this:

query.get(Source.CACHE)

say I normally get 50 documents if using the code above.now I want to delete one specific document from that query in cache, so I want to get only 49 documents.

how to do that ? is it possible ?

2 Answers 2

2

You don't have direct control over the status of the internal cache maintained by the Firebase SDKs. You can't delete or invalidate specific items.

The cache is completely managed by the SDK. The SDK determines when documents should be added or removed, based on whether or not they are in sync with the server.

You can use the SDK to delete a document, which will remove it from cached results. But that delete will eventually get synchronized with the server, and that's a permanent change.

If you have steps that show that the internal cache is somehow buggy or inconsistent with the contents of the server, then file a bug report with Firebase support that shows now to reproduce the issue.

Sign up to request clarification or add additional context in comments.

Comments

1

I want to delete one specific document from that query in cache, so I want to get only 49 documents.

There is no way you can specify that in a delete() operation. If you want to get that behavior, your device should be offline. In that way, Firestore will delete the record from the local cache. But please note, that once you regain the connection, your record will also be deleted from Firebase servers. While online, there is no way you can have a deleted document in the cache and not from Firebase servers.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.