NodeBB - Post Reputation/Likes - Find which users liked a post

188 views Asked by At

I am not able to find where does NodeBB stores the list of users who liked a particular post. For example, consider following data structure:-

> db.objects.find({_key:"post:2341"}).pretty()
{
    "_id" : ObjectId("5547af3f65190fe2122d0b3c"),
    "_key" : "post:2341",
    "edited" : 0,
    "pid" : 2341,
    "content" : "content of this post",
    "tid" : 2543,
    "timestamp" : 1412304172707,
    "deleted" : 0,
    "editor" : "",
    "uid" : 747,
    "toPid" : 19999,
    "votes" : 0,
    "reputation" : 5
}

The above says that Post ID 2341 has 5 reputations which means it is liked by 5 users. But where does it stores that these are the User IDs who liked this particular post?

1

There are 1 answers

0
khalid On BEST ANSWER

Finally hunted down for the exact key that stores it in the database via going through NodeBB code. And the particular key that stores it is pid:{postid}:upvote. So we query like this:-

>db.objects.find({_key: "pid:2341:upvote"})
{
    "_id": ObjectId("5547af3f65190fe2122d0b3c"),
    "_key": "pid:2341:upvote",
    "members": ["663", "230", "549"]
}

The above response contains the IDs of the users who upvoted a particular post.