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
Making Relational Cool Again (or: JavaScript on...
Search
Tim Griesser
May 27, 2015
Technology
1
410
Making Relational Cool Again (or: JavaScript on ACID)
JSConf 2015
Tim Griesser
May 27, 2015
Tweet
Share
More Decks by Tim Griesser
See All by Tim Griesser
SDL as an Artifact: Code-First Schemas in TS & JS
tgriesser
0
120
SDL as an Artifact: Code-First Schemas and GraphQL Nexus
tgriesser
0
170
End-to-End Testing for the Modern Web
tgriesser
0
140
Paving a New Path for GraphQL Schemas
tgriesser
0
86
Embracing the Power of GraphQL
tgriesser
2
860
Redux: A Predictable State Container for JavaScript Apps
tgriesser
2
420
The Future is Now: JavaScript, ES6, and Babel JS
tgriesser
7
1.2k
Data Based JavaScript
tgriesser
1
250
Nodevember - Making Relational Cool Again
tgriesser
1
190
Other Decks in Technology
See All in Technology
Part1 GitHubってなんだろう?その2
tomokusaba
2
770
大規模サーバーレスプロジェクトのリアルな零れ話
maimyyym
3
220
Google Cloud Next 2025 Recap アプリケーション開発を加速する機能アップデート / Application development-related features of Google Cloud
ryokotmng
0
230
本当に必要なのは「QAという技術」だった!試行錯誤から生まれた、品質とデリバリーの両取りアプローチ / Turns Out, "QA as a Discipline" Was the Key!
ar_tama
9
4.7k
Azure × MCP 入門
ry0y4n
8
1.8k
Tailwind CSS の小話「コンテナークエリーって便利」
yamaday
0
120
非root化Androidスマホでも動く仮想マシンアプリを試してみた
arkw
0
130
時間がないなら、つくればいい 〜数十人規模のチームが自律性を発揮するために試しているいくつかのこと〜
kakehashi
PRO
23
5.6k
Cursorを全エンジニアに配布 その先に見据えるAI駆動開発の未来 / 2025-05-13-forkwell-ai-study-1-cursor-at-loglass
itohiro73
2
590
SaaS公式MCPサーバーをリリースして得た学び
kawamataryo
4
1.3k
Sleep-time Compute: LLM推論コスト削減のための事前推論
sergicalsix
1
130
20250514 1Passwordを使い倒す道場 vol.1
east_takumi
0
120
Featured
See All Featured
Making Projects Easy
brettharned
116
6.2k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.6k
Balancing Empowerment & Direction
lara
0
15
Documentation Writing (for coders)
carmenintech
71
4.8k
Bash Introduction
62gerente
613
210k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
The Cult of Friendly URLs
andyhume
78
6.4k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Transcript
Making Relational Cool Again @tgriesser
Making Relational Cool Again @tgriesser or: JavaScript on ACID
sequel
SQL
None
None
None
None
None
None
Functional, (prototypal) OO Loose, duck Static, strong Declarative, Procedural
Operators? + -
Operators? 0.1 + 0.2 // 0.30000000000000004
None
–Me “Languages that will probably never die.”
None
None
None
None
42-
None
None
None
None
None
None
–Matthew Daly, Stack Overflow User “A degree of antipathy toward
relational databases”
“Poorly supported compared to non- relational databases” –Matthew Daly, Stack
Overflow User
node- node- node- node- mysql postgres mariasql sqlite3
Existing SQL Libs? Common DBAPI? Higher level abstractions
Existing SQL Libs? Database specific Mix of ORM layer and
query layer No transaction api!! "Jack of All Trades" DIY: gets you most of the way there, but…
None
None
Query builder Eloquent Promises Models, Collections, Events
None
None
None
None
None
None
None
None
None
None
Connection Pooling Grammar Schema (DDL) Builder Migrations Seeding Expression Builder
DB Client Transactions
Simple Configuration
Simple Configuration WebSQL
Simple Configuration WebSQL
SQL, as you would write it
Joins
Joins with multiple clauses
Subqueries
Subqueries
Other Builder Features • Raw queries • Aggregate queries (min,
max, sum) • Column, subquery aliasing ".as()" • Normalizes missing data in inserts • Tries hard to not let you screw up
…or: JavaScript on ACID
None
Atomicity Consistency Isolation Durability
Transactions Snapshot state of the world Ability to ROLLBACK Prevent
others from altering data as you’re working with it (Locks) A little trickier to pull off in Node
1. Register a user, giving them an ID 2. Send
that to a third party service, registering the user 3. Create additional account rows 4. Return response to the user
None
1. Register a user, giving them an ID 2. Send
that to a third party service, registering the user catch, rollback 1 3. Create additional account rows catch, rollback 1, 3? 4. Return response to the user
None
None
None
None
None
Nesting Transactions SAVEPOINT ROLLBACK TO _____
"Batteries Included" • Pooling • Schema Building • Migrations •
Seeding • Callbacks (.asCallback) • Streams (.pipe, .stream) • Events • .toString()
None
Object Relational Mapper
Object Relational Mapper • Takes care of standard SQL queries
for you, especially for common CRUD operations • model.fetch() • model.fetchAll() • model.save() • model.destroy()
• One-To-One • hasOne • belongsTo • One-To-Many • hasMany
• Many-To-Many • belongsToMany Association Types
• One-To-One • hasOne • belongsTo • One-To-Many • hasMany
• Many-To-Many • belongsToMany Association Types
• One-To-One • hasOne • belongsTo • One-To-Many • hasMany
• Many-To-Many • belongsToMany Association Types
• Mapping a single model to multiple model types •
Picture for employees, for products Polymorphic Associations
Builds on Knex
None
None
Eager Loading • Avoids the N+1 Query Problem • Find
an account with associated posts, the comments on those posts, and the accounts that made the comments.
None
Eager Loading • Avoids the N+1 Query Problem • Find
an account with "approved" associated posts, the comments on those posts, and the accounts that made the comments.
Dynamically constrain relations
Eager Loading
"Tapping into" the query chain Allows for adding additional query
parameters dynamically to the model's query
Transactions In Bookshelf, each async call (fetch, save, create, load,
destroy), takes an “options” object which may optionally take a {transacting: t} - where “t” is the object in the transaction closure
None
None
None
Shared models: Sounds great, not as great in practice
None
None
…not the first to do this
…not the last to do this
None
None
None
None
None
None
None
None
None
None
Just some of what's out there…
…this still isn't enough
Don't Reinvent the wheel
Don't Reinvent the wheel
! Reinvent the wheel
! Reinvent the wheel*
! Reinvent the wheel* * just not on the client
side…
! Reinvent the wheel* * just not on the client
side…
! Reinvent the wheel
Take a look at other libraries
Take a look at other languages
Node: a target for traditional "CRUD" web applications
Thanks! @tgriesser