If you have any query feel free to chat us!
Happy Coding! Happy Learning!
To set up the schema for likes, we need to consider the following:
With the above considerations, we can set up the schema for likes as follows:
Here, the likeable_id
and likeable_type
are used to define a polymorphic relationship with either the posts
or comments
table.
Here, we have added the likes_count
column to the posts
and comments
tables to keep track of the total number of likes for a post or a comment.
With the above schema, we can create a new like by inserting a record into the likes
table with the likeable_id
, likeable_type
, and user_id
. We can then increment the likes_count
for the corresponding post or comment. We can also check if a user has already liked a post or a comment by querying the likes
table for a record with the given likeable_id
, likeable_type
, and user_id
.
Comments: 2
I am not able to access videos from second class and further. I have already completed first class
When will I get my course?
Now, Your query was resolved.