Change default create method from save to create for remoting
This commit is contained in:
parent
c8bfc5802a
commit
7684fe2946
|
@ -162,6 +162,7 @@ DataAccessObject.create = function (data, callback) {
|
|||
DataAccessObject.create.shared = true;
|
||||
DataAccessObject.create.accepts = {arg: 'data', type: 'object'};
|
||||
DataAccessObject.create.returns = {arg: 'data', type: 'object'};
|
||||
DataAccessObject.create.http = {verb: 'post', path: '/'};
|
||||
|
||||
function stillConnecting(schema, obj, args) {
|
||||
if (schema.connected) return false; // Connected
|
||||
|
@ -532,7 +533,6 @@ DataAccessObject.prototype.save = function (options, callback) {
|
|||
DataAccessObject.prototype.save.shared = true;
|
||||
DataAccessObject.prototype.save.returns = {arg: 'obj', type: 'object'};
|
||||
DataAccessObject.prototype.save.http = [
|
||||
{verb: 'post', path: '/'},
|
||||
{verb: 'put', path: '/'}
|
||||
];
|
||||
|
||||
|
|
|
@ -111,7 +111,9 @@ ModelBuilder.prototype.define = function defineClass(className, properties, sett
|
|||
// every class can receive hash of data as optional param
|
||||
var ModelClass = function ModelConstructor(data, schema) {
|
||||
ModelBaseClass.apply(this, arguments);
|
||||
hiddenProperty(this, 'schema', schema || this.constructor.schema);
|
||||
if(!this.schema) {
|
||||
hiddenProperty(this, 'schema', schema || this.constructor.schema);
|
||||
}
|
||||
};
|
||||
|
||||
// mix in EventEmitter
|
||||
|
@ -199,7 +201,13 @@ ModelBuilder.prototype.define = function defineClass(className, properties, sett
|
|||
}
|
||||
});
|
||||
|
||||
return schema.define(className, p, s, ModelClass);
|
||||
var c = schema.define(className, p, s, ModelClass);
|
||||
|
||||
if(typeof c.setup === 'function') {
|
||||
c.setup.call(c);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
ModelClass.registerProperty = function (attr) {
|
||||
|
|
|
@ -34,7 +34,10 @@ ModelBaseClass.prototype._initProperties = function (data, applySetters) {
|
|||
var self = this;
|
||||
var ctor = this.constructor;
|
||||
|
||||
var ds = ctor.schema.definitions[ctor.modelName];
|
||||
var ds = {
|
||||
properties: ctor.properties,
|
||||
setters: ctor.settings
|
||||
};
|
||||
|
||||
var properties = ds.properties;
|
||||
data = data || {};
|
||||
|
@ -133,7 +136,7 @@ ModelBaseClass.defineProperty = function (prop, params) {
|
|||
};
|
||||
|
||||
ModelBaseClass.whatTypeName = function (propName) {
|
||||
var prop = this.schema.definitions[this.modelName].properties[propName];
|
||||
var prop = this.properties[propName];
|
||||
if (!prop || !prop.type) {
|
||||
throw new Error('Undefined type for ' + this.modelName + ':' + propName);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue