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

Commit 63d2aa6a by Sascha Depold

renamed assoc getters to get*

1 parent cb72b05e
......@@ -163,7 +163,7 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o
type: 'hasOne'
})
table.prototype[assocName] = function(callback) {
table.prototype[Sequelize.Helper.SQL.addPrefix('get', assocName)] = function(callback) {
var whereConditions = {}
whereConditions[table.identifier] = this.id
_table.find(whereConditions, callback)
......@@ -172,7 +172,7 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o
table.prototype[Sequelize.Helper.SQL.addPrefix('set', assocName)] = function(object, callback) {
var self = this
this[assocName](function(currentAssociation) {
this[Sequelize.Helper.SQL.addPrefix('get', assocName)](function(currentAssociation) {
var attr = {}
if(currentAssociation == null) {
attr[table.identifier] = self.id
......@@ -200,7 +200,7 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o
type: 'belongsTo'
})
table.prototype[assocName] = function(callback) {
table.prototype[Sequelize.Helper.SQL.addPrefix('get', assocName)] = function(callback) {
if((this[_table.identifier] == null)||(isNaN(this[_table.identifier])))
callback([])
else
......@@ -211,7 +211,7 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o
var attr = {}; attr[object.table.identifier] = object.id
var self = this
this.updateAttributes(attr, function() {
self[assocName](callback)
self[Sequelize.Helper.SQL.addPrefix('get', assocName)](callback)
})
}
......
......@@ -134,7 +134,7 @@ module.exports = {
'hasMany': function(assert) {
var HasManyBlubb = s.define('HasManyBlubb', {})
Day.hasMany('HasManyBlubbs', HasManyBlubb)
assert.isDefined(new Day({name:''}).HasManyBlubbs)
assert.isDefined(new Day({name:''}).getHasManyBlubbs)
},
'hasMany: set association': function(assert, beforeExit) {
var assoc = null
......@@ -169,7 +169,7 @@ module.exports = {
var Day = s.define('Day2', { name: Sequelize.TEXT })
var HasOneBlubb = s.define('HasOneBlubb', {})
Day.hasOne('HasOneBlubb', HasOneBlubb)
assert.isDefined(new Day({name:''}).HasOneBlubb)
assert.isDefined(new Day({name:''}).getHasOneBlubb)
},
'hasOne set association': function(assert, beforeExit) {
var s2 = new Sequelize('sequelize_test', 'test', 'test', {disableLogging: true})
......@@ -197,7 +197,7 @@ module.exports = {
'belongsTo': function(assert) {
var BelongsToBlubb = s.define('BelongsToBlubb', {})
Day.belongsTo('BelongsToBlubb', BelongsToBlubb)
assert.isDefined(new Day({name:''}).BelongsToBlubb)
assert.isDefined(new Day({name:''}).getBelongsToBlubb)
},
'belongsTo: set association': function(assert, beforeExit) {
var s2 = new Sequelize('sequelize_test', 'test', 'test', {disableLogging: true})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!