Sequelize.js 与SequelizeJ的问题和关系

Sequelize.js 与SequelizeJ的问题和关系,sequelize.js,Sequelize.js,我想根据关联模型的参数更改模型中的值 我不知道如何在我的预约模式中获得客户的性别 var Appointment = db.define('Appointment', { title: { type: Types.STRING, validate: { len: { args: [1, 50], msg: 'Vous devez saisir un titre entr

我想根据关联模型的参数更改模型中的值

我不知道如何在我的预约模式中获得客户的性别

var Appointment = db.define('Appointment', {
    title: {
        type: Types.STRING,
        validate: {
            len: {
                args: [1, 50],
                msg: 'Vous devez saisir un titre entre 1 et 50 caractères.'
            }
        }
    },
    start: {
        type: Types.DATE
    },
    end: {
        type: Types.DATE
    },
    backgroundColor: {
        type: Types.STRING,
        defaultValue: 'red'
        set: function(value){
            // if Customer.gender === 'M' >> this.backgroundColor = 'red'
            // if Customer.gender === 'F' >> this.backgroundColor = 'yellow'
        }
    }
}, {
    classMethods:{
        associate: function (models) {
            Appointment.belongsTo(models.Customer, {as: 'Customer'});
        }
    }
});
您可以使用:

Appointment.find({ where : {id :1},
                   include  : User })
.success(function(appointment){
    console.log(appointment); // visualize your instance
    appointment.user.gender;
});
更多资讯: 查找选项
[选项.包括]


也许这也是一个很好的答案:

执行查询并更改此查询的值不会起作用?会起作用,但在模型中是否可以这样做?