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

Commit 85ab07cb by Jan Aagaard Meier

A bit of style changes

1 parent 4d52706a
......@@ -88,15 +88,9 @@ module.exports = (function() {
var association = this
instancePrototype[this.accessors.set] = function(associatedInstance, options) {
var value
if (associatedInstance) {
if (associatedInstance instanceof association.target.Instance) {
value = associatedInstance[association.targetIdentifier]
} else {
value = associatedInstance
}
} else {
value = null
var value = associatedInstance
if (associatedInstance instanceof association.target.Instance) {
value = associatedInstance[association.targetIdentifier]
}
this.set(association.identifier, value)
......
......@@ -265,18 +265,18 @@ module.exports = (function() {
return new Class(association, this).injectGetter(options, queryOptions)
}
obj[this.accessors.hasAll] = function(objects, options) {
obj[this.accessors.hasAll] = function(instances, options) {
var instance = this
, where
options = options || {}
objects.forEach(function (o) {
if (o instanceof association.target.Instance) {
where = new Utils.or([where, o.primaryKeyValues])
instances.forEach(function (instance) {
if (instance instanceof association.target.Instance) {
where = new Utils.or([where, instance.primaryKeyValues])
} else {
var _where = {}
_where[association.target.primaryKeyAttribute] = o
_where[association.target.primaryKeyAttribute] = instance
where = new Utils.or([where, _where])
}
})
......@@ -290,21 +290,21 @@ module.exports = (function() {
options,
{ raw: true }
).then(function(associatedObjects) {
return associatedObjects.length === objects.length
return associatedObjects.length === instances.length
})
}
obj[this.accessors.hasSingle] = function(o, options) {
obj[this.accessors.hasSingle] = function(param, options) {
var instance = this
, where
options = options || {}
if (o instanceof association.target.Instance) {
where = o.primaryKeyValues
if (param instanceof association.target.Instance) {
where = param.primaryKeyValues
} else {
where = {}
where[association.target.primaryKeyAttribute] = o
where[association.target.primaryKeyAttribute] = param
}
options.where = new Utils.and([
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!