Get the first record of model in emberjs
10,441
You have firstObject, lastObject and objectAt.
items.get('firstObject');
Related videos on Youtube
Author by
MBehtemam
Mohammad Bagher Ehtemam (MBehtemam) => MB Coding Loving MEMEX
Updated on June 04, 2022Comments
-
MBehtemam almost 2 years
I need a way to get first record of specific model .at this time im using a way like this :
this.store.findAll('configModel').then(function(items) { items.get('content')[0].set('isEnableShowUniqueName', true); items.get('content')[0].set('isSavedToServer', false); items.get('content')[0].save(); });
but I think there is a better and ember way out there? is this way true? do you know any better way? but know this I haven't id of record I need the only first record of the model.
-
Michal Stefanow almost 9 yearsHere is a github issue using it: github.com/emberjs/data/issues/551#issuecomment-31436785
-
SuperUberDuper almost 7 yearsthere has to be a better way to write this when Ember moves to typescript