Store item against user, or user against item?

Hmm, I had something similar a few years ago, but not with “kittens”. The developer is right; it’s not a got approach to store it in a local storage, as it is local. If you switch from desktop to mobile or vice versa, you will not have your kitten history. This is why you should store it in DB.

So the best approach is to have a relationship called Viewed kittens where User has many kittens. So when you are authenticated and make a GET request to /kittens, you get their IDs and verify if the user has a relationship with them under Viewed kittens. In that case, you mark that kitten with a new field called: viewed: true. Otherwise, add a field viewed: false. You will receive all kittens in the frontend, but now you have that additional variable viewed and you can do your magic with it.

1 Like