April 2020
Intermediate to advanced
292 pages
6h 50m
English
Okay, we left the record viewings application here having written the HTTP handlers. The one that we wrote called actions.recordViewing. Now we’re going to write that action and record the viewing:
| | function createActions ({ |
| | db |
| | }) { |
| | function recordViewing (traceId, videoId) { |
| | } |
| | |
| | return { |
| | recordViewing |
| | } |
| | } |
This puts a shell in for that function. Let’s discuss what this function needs to do.
Its job is to alter system state to reflect that a video has been viewed. We’re also doing this in the context of providing a global count of all videos watched.
We already have a database table that could hold this data—you wrote the migration for it. You could simply ...
Read now
Unlock full access