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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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フル活用時代だからこそ学んでおきたい働き方の心得
shinoyu
0
120
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
400
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
610
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
0
990
rack-attack gemによるリクエスト制限の失敗と学び
pndcat
0
260
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
1.9k
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.2k
humanlayerのブログから学ぶ、良いCLAUDE.mdの書き方
tsukamoto1783
0
160
CSC307 Lecture 06
javiergs
PRO
0
670
例外処理とどう使い分ける?Result型を使ったエラー設計 #burikaigi
kajitack
16
5.8k
ZJIT: The Ruby 4 JIT Compiler / Ruby Release 30th Anniversary Party
k0kubun
1
390
CSC307 Lecture 02
javiergs
PRO
1
770
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.7k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
Chasing Engaging Ingredients in Design
codingconduct
0
110
Measuring & Analyzing Core Web Vitals
bluesmoon
9
740
How STYLIGHT went responsive
nonsquared
100
6k
Become a Pro
speakerdeck
PRO
31
5.8k
Visualization
eitanlees
150
17k
Producing Creativity
orderedlist
PRO
348
40k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
48
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
61
52k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
64
GraphQLとの向き合い方2022年版
quramy
50
14k
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