How should I store favorited posts?

I have a simple website that allows users "like" posts that other users have submitted.

As a user, I want to be able to search the posts that I have liked.

How should I structure my data, assuming my data looks like this:

{
    "title": String,
    "description": String
    "author": {
        full_name: String
        user_id: Number
    }
}

I do not want to have to maintain an index for every user.

Thanks for your inputs!

Treat it as time-based, event info an just store each like as a single event, with a link to the post in the like event as well.

Are you referring to a journaling type of data store, such that only GET and INSERT operations are allowed and DELETE and UPDATES are not?

If we do that, then every action that any user has taken to like/unlike a post will be stored.

  1. How should I handle the situation where a user has unliked a post and exclude it from the search?
  2. This method will accumulate a lot of rows very quickly right?
  1. Just grab the last event for a given post and user.
  2. Potentially, is that a concern though? Ultimately with Elasticsearch you either need to do that or deal with merges when your doing updates, so it's not like either method is "free".

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.