Skip to content

Commit 9a21928

Browse files
committed
Allow model name by params
1 parent 7f1bdc9 commit 9a21928

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/model.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
const models = {};
22

3-
function model(data) {
3+
function model(data, modelName) {
4+
if(!data) {
5+
return this;
6+
}
7+
48
// ToDo: Validate model
59
// ToDo: Check if model already exists to merge instead of set
6-
7-
models[this.modelName] = data;
10+
var name = this.modelName || modelName;
11+
models[name] = data;
812

913
return this;
1014
}
1115

12-
function get() {
13-
return models[this.modelName] || {};
16+
function get(modelName) {
17+
var name = this.modelName || modelName;
18+
return models[name] || {};
1419
}
1520

1621

0 commit comments

Comments
 (0)