-
Notifications
You must be signed in to change notification settings - Fork 20
/
package.js
37 lines (37 loc) · 1.17 KB
/
package.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
exports.Package = function(name, store, schema, options){
if (!store) {
options = schema;
schema = store;
store = {};
}
schema = schema || {};
options = options || {};
var entityStores = {};
schema.get = function(storeName) {
var entityStore = entityStores[storeName];
if(entityStore){
return entityStore;
}
};
if (!schema.SubPackage) {
schema.SubPackage = function(name, subStore, subSchema) {
subSchema = subSchema || {};
subSchema.parentStore = model;
return entityStores[name] = exports.Package(name, subStore, subSchema, {nested: true});
};
}
if (!schema.SubModel) {
schema.SubModel = function(name, subStore, subSchema) {
subSchema = subSchema || {};
subSchema.parentStore = model;
return entityStores[name] = require("./model").SubModel(name, subStore, subSchema);
};
}
if (!options.nested) {
var model = require("./model").Model(name, store, schema);
}
else {
var model = require("./model").SubModel(name, store, schema);
}
return model;
};