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
400
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
160
End-to-End Testing for the Modern Web
tgriesser
0
140
Paving a New Path for GraphQL Schemas
tgriesser
1
86
Embracing the Power of GraphQL
tgriesser
2
810
Redux: A Predictable State Container for JavaScript Apps
tgriesser
2
410
The Future is Now: JavaScript, ES6, and Babel JS
tgriesser
7
1.2k
Data Based JavaScript
tgriesser
1
240
Nodevember - Making Relational Cool Again
tgriesser
1
190
Other Decks in Technology
See All in Technology
『衛星データ利用の方々にとって近いようで触れる機会のなさそうな小話 ~ 衛星搭載ソフトウェアと衛星運用ソフトウェア (実物) を動かしながらわいわいする編 ~』 @日本衛星データコミニティ勉強会
meltingrabbit
0
120
データの品質が低いと何が困るのか
kzykmyzw
6
1k
関東Kaggler会LT: 人狼コンペとLLM量子化について
nejumi
3
460
日経電子版 x AIエージェントの可能性とAgentic RAGによって提案書生成を行う技術
masahiro_nishimi
1
290
AWSでRAGを実現する上で感じた3つの大事なこと
ymae
3
1k
君も受託系GISエンジニアにならないか
sudataka
2
370
組織貢献をするフリーランスエンジニアという生き方
n_takehata
1
1k
PL900試験から学ぶ Power Platform 基礎知識講座
kumikeyy
0
110
【Developers Summit 2025】プロダクトエンジニアから学ぶ、 ユーザーにより高い価値を届ける技術
niwatakeru
2
890
7日間でハッキングをはじめる本をはじめてみませんか?_ITエンジニア本大賞2025
nomizone
2
1.4k
ビジネスと現場活動をつなぐソフトウェアエンジニアリング~とあるスタートアッププロダクトの成長記録より~
mizunori
0
210
明日からできる!技術的負債の返済を加速するための実践ガイド~『ホットペッパービューティー』の事例をもとに~
recruitengineers
PRO
3
100
Featured
See All Featured
Producing Creativity
orderedlist
PRO
343
39k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Raft: Consensus for Rubyists
vanstee
137
6.8k
It's Worth the Effort
3n
184
28k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Side Projects
sachag
452
42k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.3k
Navigating Team Friction
lara
183
15k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
99
18k
Automating Front-end Workflow
addyosmani
1367
200k
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