1
0
mirror of https://github.com/flarum/core.git synced 2025-05-10 09:26:03 +02:00

Add convenience method to get a record by a property

This commit is contained in:
Toby Zerner 2015-05-05 17:05:16 +09:30
parent 1eef01da05
commit e0936d8100

View File

@ -50,6 +50,10 @@ export default class Store {
return this.data[type] && this.data[type][id];
}
getBy(type, key, value) {
return this.all(type).filter(model => model[key]() == value)[0];
}
all(type) {
var data = this.data[type];
return data ? Object.keys(data).map(id => data[id]) : [];