I'm playing around with my first full stack experience and I would like to start with the right foot.
Let's say I'm using MongoDb with a collection called Item, and I know that its properties are updated rarely.
Item {
"_id":ObjectId
// ...
}
Say I have a client application (a mobile device) that is able to persist data fetched from the server.
I want the user to always have the latest updated items every time he/she refreshes the UI (e.g. opens the app), but I don't want to overload the server database with requests given the fact the Items fetched would probably be already present in the local storage.
My question is whether it is wise to use a "version" property that checks if the Item on the mobile device is the same as the one of the server. Something like
V {
"_id_of_the_Item": "version_of_the_Item"
}
that allows me to check if client_version < server_version
.
This also implies the client should be sending the server a list of (ids+versions
) or let the server keep track of each user's latest fetch.
- Thinking about this solution I realized that given N Items I would have also N
V-documents
. Am I then introducing an overhead instead of reducing the number of request to the database, making them (N+M) where M is the number of Items that were updated and actually need to be fetched? - Is there any consolidated pattern for this?
Aucun commentaire:
Enregistrer un commentaire