Hello, I’d like to ask 2 questions about Master Data, but first let me give some context on what I’m doing.
It’s a feature for rating custom pages within VTEX. I’m storing the ratings in Master Data and need to increment/decrement the rating values based on the user’s score from 1–5 stars.
My first question is: is there any native way to increment/decrement integer fields in Master Data? Right now I fetch the data from Master Data, add (+1) to the rating field, and when necessary I also subtract the user’s previous rating value.
This brings me to my problem — I’m really struggling with VTEX’s cache.
Let me give an example to make it clearer:
When user A visits page X, they see these numbers:
Page X:
3 five-star ratings;
2 three-star ratings.
When they submit a 5-star rating, I build the query and get back 4 five-star ratings, but user A still sees 3 ratings. And if user B visits the page, they will also see 3 five-star ratings, and if they submit a rating, due to the cache the query will overwrite user A’s rating and also return 4 five-star ratings.
I’d like to know how I can make the query NEVER return cached data, so that whenever there’s a new rating I always fetch the most up-to-date information from Master Data.