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
300
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
240
ForwardJS - RethinkDB - Advanced Queries
thejsj
1
240
Automatic Failover in RethinkDB
thejsj
0
270
Workshop: Introduction to RethinkDB : Santa Cruz JS
thejsj
1
170
Push databases: A better way to build realtime apps
thejsj
0
150
Data Modeling in RethinkDB
thejsj
4
300
RethinkDB+Angular.js: Building realtime web applications
thejsj
10
30k
Introduction to RethinkDB: 1KE Meetup
thejsj
0
82
Introduction to RethinkDB : Hack Reactor
thejsj
4
450
Other Decks in Programming
See All in Programming
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
660
Inside Stream API
skrb
1
740
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
21
6.8k
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
210
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
180
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.2k
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
150
C# and C++ Interoperability - cho-dotnetnew
harukasao
0
280
Vite+ Unified Toolchain for the Web
naokihaba
0
320
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.4k
OSもどきOS
arkw
0
570
Featured
See All Featured
How to build a perfect <img>
jonoalderson
1
5.7k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Why Our Code Smells
bkeepers
PRO
340
58k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
140
Google's AI Overviews - The New Search
badams
0
1k
Automating Front-end Workflow
addyosmani
1370
210k
Designing for Performance
lara
611
70k
KATA
mclloyd
PRO
35
15k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
310
HDC tutorial
michielstock
2
720
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
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