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
RethinkDB Primer
Search
Marcelo Alves
April 09, 2015
Programming
2
150
RethinkDB Primer
A short introduction to RethinkDB
Marcelo Alves
April 09, 2015
Tweet
Share
Other Decks in Programming
See All in Programming
AI コーディングエージェントの時代へ:JetBrains が描く開発の未来
masaruhr
1
200
PHPで始める振る舞い駆動開発(Behaviour-Driven Development)
ohmori_yusuke
2
420
Flutterで備える!Accessibility Nutrition Labels完全ガイド
yuukiw00w
0
170
GPUを計算資源として使おう!
primenumber
1
200
VS Code Update for GitHub Copilot
74th
2
670
テスト駆動Kaggle
isax1015
1
510
Claude Code + Container Use と Cursor で作る ローカル並列開発環境のススメ / ccc local dev
kaelaela
12
6.7k
たった 1 枚の PHP ファイルで実装する MCP サーバ / MCP Server with Vanilla PHP
okashoi
1
280
A full stack side project webapp all in Kotlin (KotlinConf 2025)
dankim
0
130
テストから始めるAgentic Coding 〜Claude Codeと共に行うTDD〜 / Agentic Coding starts with testing
rkaga
15
5.3k
PHPでWebSocketサーバーを実装しよう2025
kubotak
0
310
スタートアップの急成長を支えるプラットフォームエンジニアリングと組織戦略
sutochin26
1
6.7k
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
25
1.7k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
50
5.5k
Intergalactic Javascript Robots from Outer Space
tanoku
271
27k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.5k
Documentation Writing (for coders)
carmenintech
72
4.9k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
RailsConf 2023
tenderlove
30
1.1k
The Invisible Side of Design
smashingmag
301
51k
Why You Should Never Use an ORM
jnunemaker
PRO
58
9.4k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Transcript
RethinkDB a primer
What is RethinkDB? An open-source distributed database built with .
"MongoDB with joins"
Features JSON data model Distributed joins, subqueries, aggregation and atomic
updates Hadoop-style map/reduce Friendly web and command-line administration tools Multi-datacenter replication and failover Sharding and replication Queries are automatically parallelized and distributed
Getting Started
Installation tyrion@kings-landing:~$ brew update tyrion@kings-landing:~$ brew install rethinkdb
Set Up tyrion@kings-landing:~$ rethinkdb
Web UI
Clustering tyrion@kings-landing:~$ rethinkdb create –d /tmp/db1 tyrion@kings-landing:~$ rethinkdb –j –d
/tmp/db1 --port-offset 1
Clustering
Clustering
Gem tyrion@kings-landing:~$ gem install rethinkdb [1] pry(main)> require "rethinkdb" [2]
pry(main)> include RethinkDB::Shortcuts [3] pry(main)> r.connect(host: 'localhost', database: 'marvel').repl()
Working with RethinkDB
Get All [1] pry(main)> r.table('characters').run
Get Document [1] pry(main)> r.table('characters').get(1).run
Filter [1] pry(main)> r.table('characters').filter({ age: 30 }).run
Update [1] pry(main)> r.table('characters').get(1).update({ age: 50}).run
Delete [1] pry(main)> r.table('characters').get(1).delete.run
ReQL
Principles 1. ReQL embeds into your programming language. 2. All
ReQL queries are chainable. 3. All queries execute on the server.
Embeds into your Language [1] pry(main)> require "rethinkdb" [2] pry(main)>
include RethinkDB::Shortcuts [3] pry(main)> r.connect(host: 'localhost', database: 'marvel').repl() [1] pry(main)> r.table('characters').get(1).delete.run
Chainable Queries [1] pry(main)> r.table('characters').run [2] pry(main)> r.table('characters').pluck('last_name').distinct().run [3] pry(main)>
r.table('characters').pluck('last_name').distinct().count().run
Server-Side Execution [1] pry(main)> query = r.table('characters').pluck('last_name').distinct [2] pry(main)> query.run
Examples
Filter + Contains [1] pry(main)> r.table('user').filter{|user| user['emails'].contains('
[email protected]
')}.run
Filter Dates [1] pry(main)> r.table("posts").filter{ |post| [2] pry(main)> post.during(r.time(2012, 1,
1, 'Z'), r.time(2013, 1, 1, 'Z')) [3] pry(main)> }.run
Filter + Pluck + Order + Limit [1] pry(main)> r.table('snippets').
[1] pry(main)* filter({lang: 'ruby'}). [1] pry(main)* pluck('id', 'title', 'created_at'). [1] pry(main)* order_by(r.desc('created_at')). [1] pry(main)* limit(10). [1] pry(main)* run()
Group + Merge [1] pry(main)> r.table('invoices').group( [1] pry(main)* [r.row['date'].year(), r.row['date'].month()]
[1] pry(main)* ).ungroup().merge( [1] pry(main)* {invoices: r.row['reduction'], month: r.row['group']} [1] pry(main)* ).without('reduction', 'group').order_by('month').run
Cool Features
Geospatial [1] pry(main)> point1 = r.point(-122.423246,37.779388) [2] pry(main)> point2 =
r.point(-117.220406,32.719464) [3] pry(main)> r.distance(point1, point2, {:unit => 'm'}).run [4] pry(main)> r.circle(point1, 2000).includes(point2).run
HTTP [1] pry(main)> r.table('comics').insert(r.http('http://foo.com/comics')).run
Changes [1] pry(main)> r.table('games').changes().run.each{|change| p change}
None