One final feature I'd like to show you how to perform in our application is to save the count of likes for each post in the system. This is done by using a Model.count type of query. Whenever a user likes a post object, we'll perform a simple count and update our Post to remember the number of likes that exist on a post.

Comments (7)
kencord11
4 years ago
Hi Brian, hope you're doing well. I keep getting this error: Failed to fetch posts: responseValidationFailed(reason: Alamofire.AFError.ResponseValidationFailureReason.unacceptableStatusCode(code: 401)). Everything was working fine one day and then the next day I go to run my project and I keep getting that error
Brian Voong
4 years ago
Allen Xu
3 years ago
Hey,Brain, hope u have a wonderful day. I have a problem, the count of the numberLikes. <div style="color:rgb(157,157,157);margin: 12px;font-size: 10px;"> <label>{{p.numLikes}}次赞</label> </div> but i use this, it is not the realtime to show the numLikes change. I need to refresh the website. how could I can fix this problem.
Brian Voong
3 years ago
Allen Xu
3 years ago
is that web-socket is socket.io?
Brian Voong
3 years ago
Bobur Pakhriev
3 years ago
Hey Brian, when i want to see which user liked the post by hitting the number of likes its giving me error like this : Failed to decode likes: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.})))
joeypozzyclinch
3 years ago
for me, it was a typo in my "like.js" file if you come across this problem, it's most likely a type in one of your new or edited files in Visual Studio!!!
lassesilk
3 years ago
Hi Brian. I have a issue with data being removed from the db. The strange thing is that its not all of the collections at once, by that I mean that the user collection could persist, and the posts and feeditems disappears. Do you have any idea what's going on? First I thought it was because I was updating the model file for Post in sails, but I have not been able to recreate it. I have followed along on the entire course, so I have a whitelisted IP to secure no one else can access my cluster, and I am basically clueless at this point. Thanks in advance! Great course, hope you're planning on doing more of these. Lasse
Danny S
3 years ago
hi Brian, Compares to your finished version on the right side, I think the lesson is not finished yet, why don't you show us how you added the "Friends" part in HomeController?
Setwork44
3 years ago
when I upload an avatar for any user the profile picture doesn't persist. when u log out and log back in It goes away. Also when I click on the likes I get a blank page and cant see any users
Setwork44
3 years ago
ill check my js file.. Failed to decode likes: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.})))
Setwork44
3 years ago
I fixed it! but now if I keep liking a post really quickly the numbers go up and the likes details view shows my user like 10 times! ?
Christopher J. Roura
2 years ago
Is there any guide you would recommend for MongoDB. mLab is no longer available so the next three videos cannot be followed anymore.
Brian Voong
2 years ago
Christopher J. Roura
2 years ago
Thank you
HELP & SUPPORT