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

Commit 85ab07cb by Jan Aagaard Meier

A bit of style changes

1 parent 4d52706a
...@@ -88,15 +88,9 @@ module.exports = (function() { ...@@ -88,15 +88,9 @@ module.exports = (function() {
var association = this var association = this
instancePrototype[this.accessors.set] = function(associatedInstance, options) { instancePrototype[this.accessors.set] = function(associatedInstance, options) {
var value var value = associatedInstance
if (associatedInstance) { if (associatedInstance instanceof association.target.Instance) {
if (associatedInstance instanceof association.target.Instance) { value = associatedInstance[association.targetIdentifier]
value = associatedInstance[association.targetIdentifier]
} else {
value = associatedInstance
}
} else {
value = null
} }
this.set(association.identifier, value) this.set(association.identifier, value)
......
...@@ -265,18 +265,18 @@ module.exports = (function() { ...@@ -265,18 +265,18 @@ module.exports = (function() {
return new Class(association, this).injectGetter(options, queryOptions) 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 var instance = this
, where , where
options = options || {} options = options || {}
objects.forEach(function (o) { instances.forEach(function (instance) {
if (o instanceof association.target.Instance) { if (instance instanceof association.target.Instance) {
where = new Utils.or([where, o.primaryKeyValues]) where = new Utils.or([where, instance.primaryKeyValues])
} else { } else {
var _where = {} var _where = {}
_where[association.target.primaryKeyAttribute] = o _where[association.target.primaryKeyAttribute] = instance
where = new Utils.or([where, _where]) where = new Utils.or([where, _where])
} }
}) })
...@@ -290,21 +290,21 @@ module.exports = (function() { ...@@ -290,21 +290,21 @@ module.exports = (function() {
options, options,
{ raw: true } { raw: true }
).then(function(associatedObjects) { ).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 var instance = this
, where , where
options = options || {} options = options || {}
if (o instanceof association.target.Instance) { if (param instanceof association.target.Instance) {
where = o.primaryKeyValues where = param.primaryKeyValues
} else { } else {
where = {} where = {}
where[association.target.primaryKeyAttribute] = o where[association.target.primaryKeyAttribute] = param
} }
options.where = new Utils.and([ 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!