mirror of
https://github.com/flarum/framework.git
synced 2024-12-04 08:13:39 +08:00
Simplify model registration
This commit is contained in:
parent
d4e8276b3f
commit
ba5b79451b
|
@ -9,10 +9,10 @@ import Notification from 'flarum/models/notification';
|
||||||
export default function(app) {
|
export default function(app) {
|
||||||
app.store = new Store();
|
app.store = new Store();
|
||||||
|
|
||||||
app.store.model('users', User);
|
app.store.models['users'] = User;
|
||||||
app.store.model('discussions', Discussion);
|
app.store.models['discussions'] = Discussion;
|
||||||
app.store.model('posts', Post);
|
app.store.models['posts'] = Post;
|
||||||
app.store.model('groups', Group);
|
app.store.models['groups'] = Group;
|
||||||
app.store.model('activity', Activity);
|
app.store.models['activity'] = Activity;
|
||||||
app.store.model('notifications', Notification);
|
app.store.models['notifications'] = Notification;
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,10 +55,6 @@ export default class Store {
|
||||||
return data ? Object.keys(data).map(id => data[id]) : [];
|
return data ? Object.keys(data).map(id => data[id]) : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
model(type, Model) {
|
|
||||||
this.models[type] = Model;
|
|
||||||
}
|
|
||||||
|
|
||||||
createRecord(type, data) {
|
createRecord(type, data) {
|
||||||
data = data || {};
|
data = data || {};
|
||||||
data.type = data.type || type;
|
data.type = data.type || type;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user