0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 10
click for more info
No active XP Potion
Accept a Quest
Login to submit answers
Feeds currently have a creator (the user_id
on the feed
record) but there's no way for other users to follow feeds created by other users. And because we're making feeds unique by URL, they can't even add a feed that another user has already added.
We need to introduce a many-to-many relationship between users and feeds. Many users can follow the same feed, and a user can follow many feeds.
We'll use a joining table called feed_follows
to accomplish this. Creating a feed_follow
record indicates that a user is now following a feed. Deleting it is the same as "unfollowing" a feed.
Run and submit the CLI tests.
My CreateFeedFollow
query started with a WITH
clause to insert the new record:
WITH inserted_feed_follow AS (
INSERT INTO feed_follows ...
RETURNING *
)
Now that I have the new record in the inserted_feed_follow
CTE, I can write a SELECT
query to INNER JOIN
it to the additional info I want:
SELECT
inserted_feed_follow.*,
feeds.name AS feed_name,
users.name AS user_name
FROM inserted_feed_follow
INNER JOIN ...
INNER JOIN ...
The Boot.dev CLI requires you to be signed in to submit your solution!
Copy/paste one of the following commands into your terminal:
Run
bootdev run a5f72e6a-6af3-4568-9eb7-079a3809a46c
Submit
bootdev run a5f72e6a-6af3-4568-9eb7-079a3809a46c -s
To run and submit the tests for this lesson, you must have an active Boot.dev membership
Become a member to view solution
Using the Bootdev CLI
The Bootdev CLI is the only way to submit your solution for this type of lesson. We need to be able to run commands in your environment to verify your solution.
You can install it here. It's a Go program hosted on GitHub, so you'll need Go installed as well. Instructions are on the GitHub page.