Home Feed with FeedItem
Fullstack Social iOS NodeJS REST
Now that our system is built with the capability of keeping track of following and followers for each user, it's time to move onto building out a User's feed. In short, a user's feed will consist of the posts that belong to themselves as well as users that they're following. Keep in mind that we'll need to make sure their feed is rendered in descending timestamp order. To built out a feed, its useful to declare a new model object called FeedItem that keeps track of all items belonging to a user's feed. The properties we declare on FeedItem will make it easy to query and populate for displaying UI elements in the browser.

Comments (2)
kencord11
3 years ago
Is there still a way to get all the posts from every user from the database without following another user? Meaning if I created a new user could I present that user with all the posts from the database? I’ve finished the course and I’ve been going back through the lessons trying to understand feedItems and I am trying to create two separate feeds when a user creates a post, one going to a collection of all users and one going to the followers collection
Brian Voong
3 years ago
kencord11
3 years ago
I tried this method but no posts showed up on the home page
Brian Voong
3 years ago
kencord11
3 years ago
Ohhh so I finally got the posts to show up, but it was only the posts that were posted before I created feedItems, I’m trying to figure out how to retrieve all the posts that were added to feedItems. For example, a better user experience would be if before you created an account you are able to view posts and then once you create an account and follow someone, then I would figure out a way to sort the feed DESC from following users’ posts, then the rest of the feed of the users you’re not following
Brian Voong
3 years ago
Christopher J. Roura
2 years ago
Hi Brian, I noticed two very frustrating issues. These errors by the way is nothing to do with your teaching and is just with the limitation of sails and mongo. I just want to see if you can add a video in the beginning to let others in the class be aware of these issues. 1st issue: As you had mentioned to me previously, when working with the models it can reset the database and clear out all users. It seems to be random and not occur every time but can be really confusing when a users credentials don't work and it's really because the user just no longer exists in the database and not because the username / password combo is wrong. 2nd issue: I have noticed that when saving code and running the server again through the terminal (either in vs code or though the actual terminal) there seems to be an issue of vs code adding a line to the top of the file. As an example: const FeedItem = require("../../models/FeedItem") this line appeared after I added the await function to destroy previous posts when unfollowing. this const line is added automatically by vs code at the top of the file and makes for very hard debugging and usually the way I found this error is because the compiler says TypeError: <WhateverArrayItem>.destroy is not a function. All that needs to be done is to remove that added line which is added above the module.exports line. I hope these comments are added as the errors appear more and more frequently. Now knowing these I can get back to your great content and focus on what you're teaching instead of trying to figure out where I mistyped. Thank you for your time and I am sorry for this long comment but figured it would be worth mentioning for the other students of the class. Your courses are very beneficial and I would hate for someone to be turned off by your course because of a sailsMVC/mongo problem that's out of your control.
HELP & SUPPORT