We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Posts

Time to actually store the posts in the database! We'll also add a browse command to view all the posts from the feeds the user follows, right in the terminal!

Assignment

  1. A post is a single entry from a feed. It should have:

    • id - a unique identifier for the post
    • created_at - the time the record was created
    • updated_at - the time the record was last updated
    • title - the title of the post
    • url - the URL of the post (this should be unique)
    • description - the description of the post
    • published_at - the time the post was published
    • feed_id - the ID of the feed that the post came from

    Some of these fields can probably be null, others you might want to be more strict about - it's up to you.

Again, no CLI tests for this one. Play around with the program and make sure everything works as intended!

Tips

  • Nullable SQL columns generate database/sql nullable types in sqlc, like sql.NullString and sql.NullTime.
  • Parse published_at into a sql.NullTime. If parsing fails, leave it invalid instead of crashing the scraper.