I'm considering a method that might be questionable. I'm thinking of storing a user's likes under the profile attribute in my user object. Here's an example of what it would look like:
user = {
...
profile: {
likes: [
{
user: {
_id: USER_ID,
avatar: USER_AVATAR,
username: USER_USERNAME
}
otherData: true
},
...
]
}
}
I have some reservations about this approach. One concern is that if the associated user changes their avatar, it wouldn't reflect the correct information for this user. Additionally, with an infinite amount of likes, I worry about the impact on performance as the array grows.
Is there a more efficient way to handle this? In a traditional database, I would create a separate table and use joins to retrieve a user's likes.
Cheers!