Im working on some sort of social network in which people are able to make posts about a topic and like them.
Im having trouble tracking user likes.
The schema is the following:
Users: { userId: "someId", likes: ["idPost1", "idPost4", ...] }
Posts: { postId: "someId", topic: "idTopic", postContent: "someContent"}
I need a query that can:
Take all posts from a certain topic, like this:
r.table('posts').filter({ topic: idTopic }).run().then( posts => res.json(posts))
Look up to see if the current user (given by the user id) has liked any of the posts on that specific topic. Then return a JSON with all posts on that topic, and those liked by the user with "liked: true".
Im having trouble with step 2,
Please let me know if im modelling data the wrong way, or if you can think of any way I can accomplish step 2.
Thanks!