Fireship · @fireship
Star Review System from Scratch with Firestore + Angular
Uploaded October 19, 2017 · Length 10:11
Summary
build a five-star review system from scratch using firestore and angular
- firestore
- angular
- five-star review system
- many-to-many relationships
- firebase
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
modeling data relationships is one of
- 0:02
the single most important concerns for
- 0:03
an app developer in this episode I'm
- 0:05
going to show you how to build a
- 0:06
five-star review system from scratch
- 0:08
using the new fire stored document
- 0:10
database and angular my goal is to give
- 0:13
you a good foundation for building
- 0:14
many-to-many relationships in a no
- 0:16
sequel back-end environment the reason I
- 0:18
chose a five-star review system for this
- 0:20
episode is because the underlying
- 0:22
concepts can be applied to many
- 0:23
different features such as Facebook
- 0:25
Likes reddit votes Instagram hearts and
- 0:27
many other concepts similar to those one
- 0:30
of the most important best practices
- 0:31
with firestore is to create big
- 0:33
collections and small documents to build
- 0:36
this feature we're going to have three
- 0:38
collections in the root of the database
- 0:39
so this first collection is a user's
- 0:42
collection and the only attribute on the
- 0:44
document itself is the display name I
- 0:47
won't have time to cover user
- 0:48
authentication in this video but if
- 0:49
you're new to my channel make sure to
- 0:50
check out my previous firestore Roth
- 0:53
video to get up to speed on that so back
- 0:56
to the database our primary goal here is
- 0:58
to create a relationship between users
- 1:00
and movies through the Stars collection
- 1:02
so if you look at our movies document it
- 1:05
just has the image title and plot of the
- 1:07
movie if we jump over to the Stars
- 1:09
collection you'll see that's where all
- 1:10
the relational data is cat
- 1:12
each star document will save the movie
- 1:14
ID as well as the user ID and the value
- 1:17
of the rating and then because a user
- 1:19
can only post one review for each movie
- 1:21
I've also created a custom ID here to
- 1:23
ensure that there's no accidental data
- 1:25
duplication so we create the document ID
- 1:27
by concatenating that movie ID to the
- 1:30
user ID separated by an underscore and
- 1:32
you'll see this more once we get into
- 1:34
angular if you come from a sequel
- 1:36
background this is very similar to a
- 1:37
many-to-many through relationship so now
- 1:40
I'm jumping into my angular project I'm
- 1:42
assuming you have angularfire to version
- 1:44
5 installed what I'm going to be doing
- 1:47
today is to creating a very generic
- 1:48
middleman service that can connect
- 1:50
relationships between any two documents
- 1:52
to focus on the relationship aspect of
- 1:55
this feature I'm going to just hard code
- 1:56
a user document and movie document
- 1:59
directly in the app component so I'll


