Fireship · @fireship

Is Redis the ONLY database you need? // Fullstack app from scratch with Next.js & Redis

Uploaded January 11, 2022 · Length 13:04

Is Redis the ONLY database you need? // Fullstack app from scratch with Next.js & Redis

Summary

Building a full-text autocomplete search using Redis as a primary database with Next.js and Redis modules.

  • redis database
  • next.js
  • full-text search
  • autocomplete search
  • redis modules
  • nodejs
  • javascript

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    most developers already know that redis

  2. 0:02

    is a mega fast in-memory database often

  3. 0:04

    used as a cache to make traditional

  4. 0:06

    databases faster but what most

  5. 0:08

    developers don't know is that redis can

  6. 0:10

    also be used as a primary app database

  7. 0:12

    thanks to a suite of modules that add

  8. 0:14

    additional data structures and commands

  9. 0:16

    to core redis they can handle json data

  10. 0:18

    full text search graph relationships and

  11. 0:21

    many other features in today's video

  12. 0:22

    we'll put this claim to the test by

  13. 0:24

    building a full text autocomplete search

  14. 0:26

    inspired by something like algolia or

  15. 0:28

    elasticsearch where the user can add

  16. 0:30

    items to the database and instantly view

  17. 0:32

    the filtered results we'll build this

  18. 0:34

    project from scratch using next.js

  19. 0:36

    allowing us to use react on the front

  20. 0:38

    end and nodejs to interact with redis on

  21. 0:40

    the back end as an added bonus redis

  22. 0:42

    just released a brand new sdk called

  23. 0:44

    redis ohm that supports object mapping

  24. 0:47

    and nodejs if you're new here like and

  25. 0:48

    subscribe and you can follow along with

  26. 0:50

    the full article on fireship io let's

  27. 0:52

    first take a look at what we're building

  28. 0:54

    today we have a form that when submitted

  29. 0:56

    we'll add a new item to the database in

  30. 0:58

    redis this data would normally be saved

  31. 0:59

    as a hash data structure but a hash

  32. 1:02

    doesn't support nested objects so

  33. 1:04

    instead we'll be storing this data as

  34. 1:05

    native json thanks to the redis json

  35. 1:08

    module now after adding a few items to

  36. 1:10

    the database we may want to retrieve

  37. 1:11

    them later when i type into the search

  38. 1:13

    form field you can see that it

  39. 1:14

    automatically updates the results in the

  40. 1:16

    ui after every keystroke that's made

  41. 1:18

    possible by redis search which is an

  42. 1:20

    incredibly powerful module that can

  43. 1:22

    index all of the fields on your json

  44. 1:24

    dataset at which point you can perform

  45. 1:25

    complex queries like you would with the

  46. 1:27

    where clause in sql and aggregations

  47. 1:30

    like sum and count now we're ready to

  48. 1:31

    start building there are a few different

  49. 1:33

    ways you can get started with redis the

  50. 1:34

    easiest option is to sign up for

  51. 1:36

    rediscloud i collaborated with redis

  52. 1:38

    enterprise cloud to make this video and

  53. 1:40

    they're providing a 200 credit and also

  54. 1:42

    a chance to win a tesla model 3 if you

  55. 1:45

    use this code before january 31st so

  56. 1:47

    that's pretty awesome but more

  57. 1:48

    importantly redis is consistently the

  58. 1:50

    most loved database out there i've used

  59. 1:52

    it myself for many years and that's why

  60. 1:53

    i decided to work with them on this

  61. 1:55

    video after you sign in you'll be

  62. 1:57

    prompted to create a new subscription go

  63. 1:59

    ahead and do that and you can choose a