Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to RethinkDB: 1KE Meetup

Introduction to RethinkDB: 1KE Meetup

Jorge Silva

June 12, 2015
Tweet

More Decks by Jorge Silva

Other Decks in Programming

Transcript

  1. 1KE Tech Talks
    San Francisco, California
    June 12, 2015
    RethinkDB
    The database for the
    realtime web

    View Slide

  2. Jorge Silva
    @thejsj
    Developer Evangelist @ RethinkDB

    View Slide

  3. Preface
    Why is realtime important?

    View Slide

  4. Realtime apps

    View Slide

  5. Realtime apps

    View Slide

  6. Realtime apps
    • More and more apps are built to
    be realtime
    • Users have come to want and
    expect this behavior in their apps

    View Slide

  7. Building realtime apps is hard
    • You can keep everything in a
    single server
    • You can poll the database to keep
    track of updates
    • You can publish updates through
    a message broker

    View Slide

  8. Building realtime apps is hard
    • All solutions present a tradeoff
    between scalability and
    complexity
    • It’s hard to keep track of state in
    realtime architectures.

    View Slide

  9. Introduction
    What is RethinkDB?

    View Slide

  10. What is RethinkDB?
    • Open source database for building
    realtime web applications
    • NoSQL database that
    stores schemaless JSON documents
    • Distributed database that is easy to
    scale

    View Slide

  11. Built for Realtime Apps
    • Subscribe to change notifications
    from database queries
    • No more polling — the database
    pushes changes to your app
    • Reduce the amount of plumbing
    needed to stream live updates

    View Slide

  12. Built for Realtime Apps
    RethinkDB is an excellent database for:
    • Collaborative web and mobile apps
    • Multiplayer games
    • Streaming analytics apps
    • Realtime marketplaces
    • Connected devices

    View Slide

  13. Introduction to ReQL
    RethinkDB Query Language

    View Slide

  14. Introduction to ReQL
    • ReQL embeds natively into your
    programming language
    • Compose ReQL queries by
    chaining commands

    View Slide

  15. Anatomy of a ReQL Query
    r.table("players")
    .orderBy({
    index: r.desc("score")
    })
    .limit(3)
    Top three players by score

    View Slide

  16. Anatomy of a ReQL Query
    r.table("players")
    .orderBy({
    index: r.desc("score")
    })
    .limit(3)
    Access a database table

    View Slide

  17. Anatomy of a ReQL Query
    r.table("players")
    .orderBy({
    index: r.desc("score")
    })
    .limit(3)
    Order results

    View Slide

  18. Anatomy of a ReQL Query
    r.table("players")
    .orderBy({
    index: r.desc("score")
    })
    .limit(3)
    Use index as pre-processed lookup

    View Slide

  19. Anatomy of a ReQL Query
    r.table("players")
    .orderBy({
    index: r.desc("score")
    })
    .limit(3)
    Order results in descending order

    View Slide

  20. Anatomy of a ReQL Query
    r.table("players")
    .orderBy({
    index: r.desc("score")
    })
    .limit(3)
    Only get the first three results

    View Slide

  21. Subscribe to change notifications
    on database queries
    Changefeeds

    View Slide

  22. r.table("users").changes()
    Track changes on the users table
    Changefeeds

    View Slide

  23. Changefeeds
    r.table("players")
    .orderBy({
    index: r.desc("score")
    })
    .limit(3)
    .changes()
    Get updates on top three players

    View Slide

  24. Realtime apps
    Demo

    View Slide

  25. http://questions.rethinkdb.com
    Questions

    View Slide

  26. Additional Resources
    • RethinkDB website:

    http://rethinkdb.com
    • RethinkDB installation:

    http://rethinkdb.com/docs/
    install/

    View Slide

  27. Questions
    [email protected]
    • @thejsj

    View Slide