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
Ember Data: (Advanced) Patterns
Search
Paul Chavard
September 20, 2013
Programming
2
220
Ember Data: (Advanced) Patterns
Slides for my talk from EmberFest 2013
Paul Chavard
September 20, 2013
Tweet
Share
More Decks by Paul Chavard
See All by Paul Chavard
Le Tour du monde en quatre-vingts jours
tchak
1
32
Functional Ember
tchak
0
270
HTTP
tchak
3
180
Ember Data REBOOT
tchak
0
130
EmberJS Introduction
tchak
1
190
From SproutCore to Ember
tchak
2
240
Ember Data
tchak
11
810
Ember.js
tchak
11
1.6k
Other Decks in Programming
See All in Programming
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
180
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
130
KubeCon NA 2024の全DB関連セッションを紹介
nnaka2992
0
110
20241217 競争力強化とビジネス価値創出への挑戦:モノタロウのシステムモダナイズ、開発組織の進化と今後の展望
monotaro
PRO
0
230
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
6
1.3k
テストコード書いてみませんか?
onopon
2
290
AppRouterを用いた大規模サービス開発におけるディレクトリ構成の変遷と問題点
eiganken
1
410
為你自己學 Python
eddie
0
500
Внедряем бюджетирование, или Как сделать хорошо?
lamodatech
0
860
CloudflareStack でRAGに入門
asahiiwm
0
140
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
230
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
8
1.8k
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
3
340
What's in a price? How to price your products and services
michaelherold
244
12k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
Building Adaptive Systems
keathley
38
2.3k
GitHub's CSS Performance
jonrohan
1030
460k
The Language of Interfaces
destraynor
155
24k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
550
The Pragmatic Product Professional
lauravandoore
32
6.4k
Facilitating Awesome Meetings
lara
50
6.2k
GraphQLの誤解/rethinking-graphql
sonatard
68
10k
How GitHub (no longer) Works
holman
312
140k
YesSQL, Process and Tooling at Scale
rocio
170
14k
Transcript
Ember Data (Advanced) Patterns Paul Chavard Capitaine Train August 30,
2013
Capitaine Train capitainetrain.com • 55 controllers • 22 models
I am going to show you some useful stuff that
actualy works (most of the time) in Ember Data
Filters Dynamic Filter var IndexRoute = Ember.Route.extend ({ model: function
() { return this.store.filter(’post ’, {}, Ember.K); } }); var IndexController = Ember. ArrayController .extend ({ searchText : ’’, searchTextDidChange : function () { var searchText = this.get(’searchText ’). toLowerCase (); var filterFunction = Ember.isEmpty(searchText ) ? Ember.K : function(record) { return record.get(’title ’). toLowerCase () .match( searchText ); }; this.set(’content. filterFunction ’, filterFunction ); }. observes(’searchText ’) });
Batch Saves Save Multiple Models Ember.RSVP.all(post.get(’comments ’). invoke(’save ’)) .then(function
() { alert(’All Saved!’); }, function(reason) { alert(’There was an error because ’ + reason ); }); Save Parent Before Child post.save (). then(function () { return comment.save (); }). then(function () { alert(’All Saved!’); }, function(reason) { alert(’There was an error because ’ + reason ); });
Unload Records Unload Single Record this.store.find(’post ’, 1). unloadRecord ();
Unload Record with its Relationships var Post = DS.Model.extend ({ unloadRecord : function () { this._super (); this. eachRelationship (function(key , relationship ) { if ( relationship .kind === ’hasMany ’) { this.get(key ). toArray (). invoke(’unloadRecord ’); } else { this.get(key ). unloadRecord (); } }, this ); } }); this.store.find(’post ’, 1). unloadRecord ();
Ember Extention
The End