Fix hasMany / relational methods. Update docs.
This commit is contained in:
parent
8a7086be5c
commit
755b54f697
|
@ -136,12 +136,18 @@ Require a value for `property` to be a specific type of `Number`.
|
|||
|
||||
#### Model.validatesUniquenessOf(property, options)
|
||||
|
||||
Ensure the value for `property` is unique.
|
||||
Ensure the value for `property` is unique in the collection of models.
|
||||
|
||||
User.validatesUniquenessOf('email', {message: 'email is not unique'});
|
||||
|
||||
**Note:** not available for all [connectors](#connectors).
|
||||
|
||||
Currently supported in these connectors:
|
||||
|
||||
- [In Memory](#memory-connector)
|
||||
- [Oracle](http://github.com/strongloop/loopback-connector-oracle)
|
||||
- [MongoDB](http://github.com/strongloop/loopback-connector-mongodb)
|
||||
|
||||
#### myModel.isValid()
|
||||
|
||||
Validate the model instance.
|
||||
|
|
|
@ -116,9 +116,8 @@ loopback.createDataSource = function (name, options) {
|
|||
}
|
||||
}
|
||||
|
||||
var pluralized = i8n.pluralize(anotherClass.modelName);
|
||||
var methodName = params.as ||
|
||||
i8n.camelize(pluralized, true);
|
||||
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
|
||||
|
@ -127,12 +126,14 @@ loopback.createDataSource = function (name, options) {
|
|||
// because it is defined inside
|
||||
// a property getter...
|
||||
|
||||
this[methodName].apply(thisClass, arguments);
|
||||
var f = (this[methodName] || this[pluralized]);
|
||||
f.apply(thisClass, arguments);
|
||||
};
|
||||
|
||||
fn.shared = true;
|
||||
fn.http = {verb: 'get', path: '/' + methodName};
|
||||
fn.http = {verb: 'get', path: '/' + pluralized};
|
||||
fn.accepts = {arg: 'where', type: 'object'};
|
||||
fn.returns = {root: true};
|
||||
hasMany.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue