I am using cloud firestore in my android chat application, I want to store the all messages (incoming and outgoing, basically maintaining message history for a device) in array-list of a document, but the maximum size of a document is 1MB. What would happen if the size of document exceeds 1MB when I am trying to store the message
Is there any API is available to get the size of the document before writing?
Please suggest me better way to maintain message history using firestore?
If the document size exceeds 1MB. It will throw an error like this "Error: 3 INVALID_ARGUMENT: A document cannot be written because it exceeds the maximum size allowed."
Me too think that there is no API for getting the size of the document. One way is that, You can get the entire data from collection and stringify that, remove the white spaces and count the number of chars then add a buffer value based on the documentation https://firebase.google.com/docs/firestore/storage-size
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With