不要怂,就是干,撸起袖子干!

Commit 2ed685be by Overlook Motel

getAssociation finds by alias if provided

1 parent 38de94a5
Showing with 7 additions and 11 deletions
......@@ -59,36 +59,32 @@ Mixin.hasMany = function(associatedDAOFactory, options) {
return this
}
Mixin.getAssociation = function(target) {
var result = null
Mixin.getAssociation = function(target, alias) {
for (var associationName in this.associations) {
if (this.associations.hasOwnProperty(associationName)) {
var association = this.associations[associationName]
if (!result && (association.target === target)) {
result = association
if (association.target === target && (alias === undefined ? !association.isAliased : association.as === alias)) {
return association
}
}
}
return result
return null
}
Mixin.getAssociationByAlias = function(alias) {
var result = null
for (var associationName in this.associations) {
if (this.associations.hasOwnProperty(associationName)) {
var association = this.associations[associationName]
if (!result && (association.options.as === alias)) {
result = association
if (association.as === alias) {
return association
}
}
}
return result
return null
}
/* example for instance methods:
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!