Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Introduction to RethinkDB : Move fast and break...
Search
Jorge Silva
August 06, 2015
Programming
2
250
Introduction to RethinkDB : Move fast and break things
Jorge Silva
August 06, 2015
Tweet
Share
More Decks by Jorge Silva
See All by Jorge Silva
ForwardJS - RethinkDB - Getting Started
thejsj
0
180
ForwardJS - RethinkDB - Advanced Queries
thejsj
1
190
Automatic Failover in RethinkDB
thejsj
0
220
Workshop: Introduction to RethinkDB : Santa Cruz JS
thejsj
1
110
Push databases: A better way to build realtime apps
thejsj
0
120
Data Modeling in RethinkDB
thejsj
4
260
RethinkDB+Angular.js: Building realtime web applications
thejsj
10
30k
Introduction to RethinkDB: 1KE Meetup
thejsj
0
43
Introduction to RethinkDB : Hack Reactor
thejsj
4
400
Other Decks in Programming
See All in Programming
良いユニットテストを書こう
mototakatsu
11
3.6k
Оптимизируем производительность блока Казначейство
lamodatech
0
960
ISUCON14感想戦で85万点まで頑張ってみた
ponyo877
1
610
いりゃあせ、PHPカンファレンス名古屋2025 / Welcome to PHP Conference Nagoya 2025
ttskch
1
190
Fixstars高速化コンテスト2024準優勝解法
eijirou
0
190
自動で //nolint を挿入する取り組み / Gopher's Gathering
utgwkk
1
100
chibiccをCILに移植した結果 (NGK2025S版)
kekyo
PRO
0
150
Alba: Why, How and What's So Interesting
okuramasafumi
0
220
混沌とした例外処理とエラー監視に秩序をもたらす
morihirok
14
2.4k
令和7年版 あなたが使ってよいフロントエンド機能とは
mugi_uno
11
5.3k
BEエンジニアがFEの業務をできるようになるまでにやったこと
yoshida_ryushin
0
200
“あなた” の開発を支援する AI エージェント Bedrock Engineer / introducing-bedrock-engineer
gawa
5
550
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.7k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.6k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.4k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.5k
Agile that works and the tools we love
rasmusluckow
328
21k
A Modern Web Designer's Workflow
chriscoyier
693
190k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Why Our Code Smells
bkeepers
PRO
335
57k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.2k
GraphQLとの向き合い方2022年版
quramy
44
13k
Transcript
Push databases, RethinkDB, and building realtime apps Move Fast and
Break Things San Francisco, CA August 5, 2015
Jorge Silva Developer Evangelist @ RethinkDB @thejsj
Preface The realtime web
Realtime apps
Realtime apps
Realtime apps • More and more apps are built to
be realtime • Users have come to want and expect this behavior in their apps • Building realtime apps is hard
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
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
Introduction What is RethinkDB?
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
Push Database • Subscribe to change notifications from database queries
(changefeeds) • No more polling — the database pushes changes to your app • Reduce the amount of plumbing needed to stream live updates
Push Database • Having your database push changes keeps your
database as the central source of truth • Having a central source of truth simplifies your architecture
Push Database RethinkDB is an excellent database for: • Collaborative
web and mobile apps • Multiplayer games • Streaming analytics apps • Connected devices
Introduction to ReQL RethinkDB Query Language
Introduction to ReQL • ReQL embeds natively into your programming
language • Compose ReQL queries by chaining commands
Anatomy of a ReQL Query r.table("users") .pluck("last_name") .distinct().count() Number of
unique last names
Anatomy of a ReQL Query r.table("users") .pluck("last_name") .distinct().count() Access a
database table
Anatomy of a ReQL Query r.table("users") .pluck("last_name") .distinct().count() Isolate a
document property
Anatomy of a ReQL Query r.table("users") .pluck("last_name") .distinct().count() Consolidate duplicate
values
Anatomy of a ReQL Query r.table("users") .pluck("last_name") .distinct().count() Display the
number of items
Sample ReQL Queries r.table("users") .filter(r.row("age").gt(30)) r.table(“post") .eqJoin(“uId”, r.table(“users”)) .zip() r.table("fellowship")
.filter({species: "hobbit"}) .update({species: "halfling"})
Additional ReQL Features • Geospatial indexing for location- based queries
• Date and time functions • Support for storing binary objects • Execute http requests using r.http
Realtime Updates Working with Changefeeds
Subscribe to change notifications on database queries Changefeeds
r.table("users").changes() Track changes on the users table Changefeeds
Changefeeds • The changes command returns a cursor that receives
updates • Each update includes the new and old value of the modified record
Changefeeds r.table("users").changes() r.table("users") .insert({name: "Bob"}) Changefeed output: { new_val: {
id: '362ae837-2e29-4695-adef-4fa415138f90', name: 'Bob', ... }, old_val: null }
Changefeeds r.table("users").changes() r.table("users") .filter({name: "Bob"}).delete() Changefeed output: { new_val: null,
old_val: { id: '362ae837-2e29-4695-adef-4fa415138f90', name: 'Bob', ... } }
Changefeeds r.table("users").changes() r.table("users") .get("362ae837-2e29-4695-adef-4fa415138f90") .update({name: "Bobby"}) Changefeed output: { new_val:
{ id: '362ae837-2e29-4695-adef-4fa415138f90', name: 'Bobby' }, old_val: { id: '362ae837-2e29-4695-adef-4fa415138f90', name: 'Bob' } }
Changefeeds r.table("players") .orderBy({index: r.desc("score")}) .limit(3).changes() Track top three players by
score Chain the changes command to an actual ReQL query:
Questions http://questions.rethinkdb.com
Summary • Keeping track of state in realtime apps is
hard • RethinkDB solves this problem by pushing changes to your app • In the future, we'll see more database that use the push model
Questions • RethinkDB website: http://rethinkdb.com • Install RethinkDB: http://rethinkdb.com/install/ •
Email me:
[email protected]
• Tweet: @thejsj, @rethinkdb