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:
parent
1eef01da05
commit
e0936d8100
@ -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]) : [];
|
||||
|
Loading…
x
Reference in New Issue
Block a user