diff --git a/lib/loopback.js b/lib/loopback.js index e424a358..e516de56 100644 --- a/lib/loopback.js +++ b/lib/loopback.js @@ -94,54 +94,10 @@ loopback.createDataSource = function (name, options) { ds.createModel = function (name, properties, settings) { var ModelCtor = loopback.createModel(name, properties, settings); ModelCtor.attachTo(ds); - - var hasMany = ModelCtor.hasMany; - - if(hasMany) { - ModelCtor.hasMany = function (anotherClass, params) { - var origArgs = arguments; - var thisClass = this, thisClassName = this.modelName; - params = params || {}; - if (typeof anotherClass === 'string') { - params.as = anotherClass; - if (params.model) { - anotherClass = params.model; - } else { - var anotherClassName = i8n.singularize(anotherClass).toLowerCase(); - for(var name in this.schema.models) { - if (name.toLowerCase() === anotherClassName) { - anotherClass = this.schema.models[name]; - } - } - } - } - - var pluralized = anotherClass.pluralModelName || i8n.pluralize(anotherClass.modelName); - var methodName = params.as || i8n.camelize(i8n.pluralize(anotherClass.modelName), true); - var proxyMethodName = 'get' + i8n.titleize(pluralized, true); - - // create a proxy method - var fn = this.prototype[proxyMethodName] = function () { - // this[methodName] cannot be a shared method - // because it is defined inside - // a property getter... - - var f = (this[methodName] || this[pluralized]); - f.apply(thisClass, arguments); - }; - - fn.shared = true; - fn.http = {verb: 'get', path: '/' + pluralized}; - fn.accepts = {arg: 'where', type: 'object'}; - fn.returns = {root: true}; - hasMany.apply(this, arguments); - }; - } - return ModelCtor; - } + }; return ds; -} +}; /** * Create a named vanilla JavaScript class constructor with an attached set of properties and options.