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

Commit 36c179e9 by sdepold

moved require's out of functions and declared it at the top of the file

1 parent 76c5ac79
Showing with 4 additions and 4 deletions
var Utils = require("./../utils")
var Utils = require("./../utils")
, HasOne = require('./has-one')
, HasMany = require("./has-many")
, BelongsTo = require("./belongs-to")
/* Defines Mixin for all models. */
var Mixin = module.exports = function(){}
Mixin.hasOne = function(associatedModel, options) {
// the id is in the foreign table
var HasOne = require('./has-one')
var association = new HasOne(this, associatedModel, Utils._.extend((options||{}), this.options))
this.associations[association.associationAccessor] = association.injectAttributes()
return this
}
Mixin.belongsTo = function(associatedModel, options) {
// the id is in this table
var BelongsTo = require("./belongs-to")
var association = new BelongsTo(this, associatedModel, Utils._.extend((options||{}), this.options))
this.associations[association.associationAccessor] = association.injectAttributes()
return this
}
Mixin.hasMany = function(associatedModel, options) {
// the id is in the foreign table or in a connecting table
var HasMany = require("./has-many")
var association = new HasMany(this, associatedModel, Utils._.extend((options||{}), this.options))
this.associations[association.associationAccessor] = association.injectAttributes()
return this
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!