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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Jorge Silva
August 06, 2015
Programming
290
2
Share
Introduction to RethinkDB : Move fast and break things
Jorge Silva
August 06, 2015
More Decks by Jorge Silva
See All by Jorge Silva
ForwardJS - RethinkDB - Getting Started
thejsj
0
230
ForwardJS - RethinkDB - Advanced Queries
thejsj
1
230
Automatic Failover in RethinkDB
thejsj
0
260
Workshop: Introduction to RethinkDB : Santa Cruz JS
thejsj
1
150
Push databases: A better way to build realtime apps
thejsj
0
150
Data Modeling in RethinkDB
thejsj
4
290
RethinkDB+Angular.js: Building realtime web applications
thejsj
10
30k
Introduction to RethinkDB: 1KE Meetup
thejsj
0
75
Introduction to RethinkDB : Hack Reactor
thejsj
4
430
Other Decks in Programming
See All in Programming
感情を設計する
ichimichi
5
1.5k
ドメインイベントでビジネスロジックを解きほぐす #phpcon_odawara
kajitack
3
760
Kubernetes上でAgentを動かすための最新動向と押さえるべき概念まとめ
sotamaki0421
3
490
Liberating Ruby's Parser from Lexer Hacks
ydah
1
420
ハーネスエンジニアリングとは?
kinopeee
6
3.8k
3分でわかるatama plusのQA/about atama plus QA
atamaplus
0
170
Alternatives to JPA 2026
debop
0
110
Codex CLI でつくる、Issue から merge までの開発フロー
amata1219
0
360
PHP で mp3 プレイヤーを実装しよう
m3m0r7
PRO
0
270
セグメントとターゲットを意識するプロポーザルの書き方 〜採択の鍵は、誰に刺すかを見極めるマーケティング戦略にある〜
m3m0r7
PRO
0
520
UIの境界線をデザインする | React Tokyo #15 メイントーク
sasagar
2
350
Claude Codeをカスタムして自分だけのClaude Codeを作ろう
terisuke
0
130
Featured
See All Featured
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
110
Docker and Python
trallard
47
3.8k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.2k
Optimizing for Happiness
mojombo
378
71k
Visualization
eitanlees
150
17k
How to make the Groovebox
asonas
2
2.1k
Accessibility Awareness
sabderemane
0
100
Art, The Web, and Tiny UX
lynnandtonic
304
21k
How to Think Like a Performance Engineer
csswizardry
28
2.5k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
280
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