exports.Model = function(name, store, schema){ if(!schema){ schema = store; store = null; } if(!store){ store = JSFile((require("settings").dataFolder || "data") + "/" + name); } store.id = name; schema.id = name; schemas[name] = schema; if(typeof store.setSchema === "function"){ store.setSchema(schema); } if(typeof schema !== "function"){ schema = Permissive(store, schema); } schema.id = name; defineProperty(schema, "transaction", { get: function(){ return exports.currentTransaction; } }); return models[name] = schema; };
exports.SubModel = function(name, store, schema) { if(!schema){ schema = store; store = null; } if(!store){ store = JSFile((require("settings").dataFolder || "data") + "/" + name); } store.id = name; schema.id = name; function getModelPath(schema) { var path = ""; if (schema.parentStore) path = getModelPath(schema.parentStore) + "/"; return path + schema.id; } schema.getModelPath = function() { return getModelPath(schema); }; schemas[name] = schema; if(typeof store.setSchema === "function"){ store.setSchema(schema); } if(typeof schema !== "function"){ schema = Permissive(store, schema); } defineProperty(schema, "transaction", { get: function(){ return exports.currentTransaction; } }); return schema; };