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
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
Amazon Qを使ってIaCを触ろう!
maruto
0
420
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
140
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.8k
[Do iOS '24] Ship your app on a Friday...and enjoy your weekend!
polpielladev
0
110
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
6
1.6k
CSC509 Lecture 12
javiergs
PRO
0
160
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
210
Contemporary Test Cases
maaretp
0
140
デザインパターンで理解するLLMエージェントの作り方 / How to develop an LLM agent using agentic design patterns
rkaga
8
870
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
Featured
See All Featured
Statistics for Hackers
jakevdp
796
220k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
For a Future-Friendly Web
brad_frost
175
9.4k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Building Your Own Lightsaber
phodgson
103
6.1k
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