sdepold/sequelize — Issue #101: Can't specify a custom primary key AND set the id field's value
Author: mlebrun
Created: 2011-10-12 14:40:32+00:00
State: open

Obj Structure:

module.exports = function(sequelize, DataTypes) {
return sequelize.define("Project", {
my_id: DataTypes.INTEGER, primaryKey: true,
id: DataTypes.STRING,
title: DataTypes.STRING
})
}

Manipulation:

var Project = sequelize.import(__dirname + "/path/to/models/project"),
project;

project = new Project().build();

project.updateAttributes({
id: 895,
title: 'blah blah blah'
}).on('success', function() {})

// this will set title = 'blah blah blah' but the id = null