Fireship · @fireship
Reddit Inspired Upvoting System with Angular and Firebase NoSQL
Uploaded June 23, 2017 · Length 5:47
Summary
build reddit upvoting system with angular and firebase nosql
- angular
- firebase
- nosql
- upvoting system
- reddit style voting
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
in this episode we're going to build a
- 0:02
Reddit style up voting down voting
- 0:04
system using angular 4 and
- 0:06
Firebase in this example we have a
- 0:09
collection of items already in the
- 0:11
database and we also have Firebase
- 0:14
authentication set up in our app if
- 0:16
you're new to Firebase authentication
- 0:18
I've added a couple links in the
- 0:19
description with more
- 0:21
details the first thing we need to think
- 0:23
about is modeling our data in the
- 0:25
Firebase no SQL
- 0:27
database our database needs to answer
- 0:30
two fundamental
- 0:31
questions what is the user's vote for a
- 0:34
given item and What's the total vote
- 0:37
count for a given
- 0:39
item we can answer this question by
- 0:41
creating a collection based on the
- 0:43
unique ID of the
- 0:46
items for each item id we save the user
- 0:49
IDs that have voted on that item this
- 0:51
way we can query an item and see if the
- 0:53
users voted on it and we can also tally
- 0:56
up the collection of users under an item
- 0:59
to get the total vote
- 1:00
account let's start by building the
- 1:03
service the first thing we need is the
- 1:06
Firebase object observable for a
- 1:08
specific item
- 1:10
[Music]
- 1:18
id we also need the user to be able to
- 1:20
cast their vote by updating the item
- 1:23
object in the
- 1:25
database the update user vote function
- 1:28
will send a new key value pair to the
- 1:29
the item in the database with the key
- 1:31
being the user's ID and the value being
- 1:34
the value of the boat which can be
- 1:36
either A-1 zero or
- 1:41
one now we can build the upvote button
- 1:46
component our component will accept a
- 1:48
couple of input values since this is
- 1:50
normally going to be a child component
- 1:52
of an item we can go ahead and pass it
- 1:55
the item id as well as the user ID


