Forum Academy Marketplace Showcase Pricing Features

Best way to store multiple upvotes by the same user

I have a use case where users can upvote a given post multiple times. Each time a user upvotes a post, the post is awarded is 10 points (default) or a custom amount (input by the user).

I need to store this interaction i.e. for each upvote the user and the points awarded to the post.

At a high level, it feels like lists are the most efficient way to store this info. Create a separate datatype Upvote with three fields - post-id (post data type), user (list of users) and points (list of numbers). This data won’t need to be loaded very frequently.

On the Post datatype, I will store a running total of the points awarded for each post, which can be displayed quickly.

The problem with the approach is that by default - lists in bubble only store unique items. Thus, it won’t store the user into the list, when they press the upvote button, the second time around and the default points (10) will also won’t be stored.

To store each interaction as a separate row in the DB ‘feels’ rather inefficient and bloated.

Any suggestions are greatly appreciated.

I suppose one way could to be append the time-stamp to each entry and then use regex to filter it for relevant queries?

For bubble to be unable to handle such a simple use-case is at odds with the rest of its capabilities.

@mikeloc hope you don’t me tagging you here. Reading through previous posts on the forum, you have very good insights on this topic. Any help is greatly appreciated.

Hi there, @SK1… I saw your question when you initially posted it, and I stopped short of replying because if it was me, I would do exactly this and be done with it.

I understand the inefficient and bloated feeling of that approach, of course, but regardless, I think it’s the way to go.

Sorry, but that’s all I’ve got on this one, and I hope it helps.

Best…
Mike

2 Likes

Thanks @mikeloc. Really appreciate your input. I will go with separate rows.

1 Like