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
210
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
120
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
ゆるい個人開発のススメ
kuroppe1819
10
1k
try! Swift Tokyo 2024 参加報告 / try! Swift Tokyo 2024 Report
hironytic
0
220
Node.js v22 で変わること
yosuke_furukawa
PRO
11
3.9k
AmperとFleetを使ったAndroidアプリ
yoppie
0
250
Anthropic Cookbook のおすすめレシピ
schroneko
7
1.1k
Compose-View Interop in Practice (mDevCamp 2024)
stewemetal
0
160
Behind VS Code Extensions for JavaScript / TypeScript Linnting and Formatting
unvalley
5
1.1k
Site Reliability Engineering for GMO
pyama86
8
1.1k
CREってこういうこと? 体験入社 - 提案資料 - / what-is-cre-trial-employment
shinden
1
490
Going beyond Apache Parquet's default settings
xhochy
0
120
What We Can Learn From OSS
inouehi
0
430
Ruby Function Composition
bkuhlmann
1
340
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
6
3.4k
How to train your dragon (web standard)
notwaldorf
74
5.2k
Teambox: Starting and Learning
jrom
128
8.4k
The World Runs on Bad Software
bkeepers
PRO
61
6.7k
Fantastic passwords and where to find them - at NoRuKo
philnash
38
2.5k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
13
8.3k
Fireside Chat
paigeccino
22
2.6k
Designing on Purpose - Digital PM Summit 2013
jponch
111
6.5k
Facilitating Awesome Meetings
lara
43
5.6k
Navigating Team Friction
lara
179
13k
Become a Pro
speakerdeck
PRO
12
4.6k
Testing 201, or: Great Expectations
jmmastey
29
6.4k
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