There are a few ways to efficiently store and retrieve likes in Firestore/Document DB:
Create a separate collection for Likes: Store the likes in a separate collection and use the document ID to link it to the main document. This allows for efficient queries and updates of like data, without affecting the main document.
Use an Array in the Main Document: Store the likes as an array inside the main document. This allows for quick access and updates to the likes, but can become inefficient when the array gets too large.
Use a Subcollection for the Likes: Similar to option 1, create a subcollection for likes under each main document. This allows for efficient queries and updates of like data, without affecting the main document.
Use a Map in the Main Document: Store the likes as a map inside the main document. This allows for quick access and updates to the likes, but like an array, it can become inefficient when the map gets too large.
When retrieving likes from Firestore/Document DB, it is important to consider pagination, so that large amounts of data can be retrieved in chunks. Additionally, queries should be optimized to minimize the amount of data being sent back from the server.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-30 01:44:31 +0000
Seen: 9 times
Last updated: Jun 30 '23
How can one ensure that sub-classes have uniform method parameters in TypeScript?
How can the calculation of matrix determinant be performed using CUDA?
How can code repetition be prevented when using (box)plot functions?
When I attempt to generate a database, why does the azure-cosmos-emulator become unresponsive?
What steps can I take to prevent my webpage from slowing down when all parts of a div are displayed?