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

Commit ba9e5e46 by Jan Aagaard Meier

added options to specify whitelist when creating

1 parent 32e7f27d
......@@ -187,8 +187,8 @@ module.exports = (function() {
return instance
}
DAOFactory.prototype.create = function(values) {
return this.build(values).save()
DAOFactory.prototype.create = function(values, fields) {
return this.build(values).save(fields)
}
DAOFactory.prototype.__defineGetter__('primaryKeys', function() {
......
......@@ -97,11 +97,14 @@ module.exports = (function() {
var updatedAtAttr = this.__options.underscored ? 'updated_at' : 'updatedAt'
if(this.__options.timestamps && this.hasOwnProperty(updatedAtAttr))
this[updatedAtAttr] = new Date()
if(this.__options.timestamps && this.hasOwnProperty(updatedAtAttr)) {
var now = new Date()
this[updatedAtAttr] = now
values[updatedAtAttr] = now
}
if(this.isNewRecord) {
return this.QueryInterface.insert(this, this.__factory.tableName, this.values)
return this.QueryInterface.insert(this, this.__factory.tableName, values)
} else {
var identifier = this.__options.hasPrimaryKeys ? this.primaryKeyValues : this.id
, tableName = this.__factory.tableName
......
......@@ -411,7 +411,7 @@ describe('DAO', function() {
var now = Date.now()
, user = null
, updatedAt = null
Helpers.async(function(done) {
// timeout is needed, in order to check the update of the timestamp
setTimeout(function() {
......@@ -425,8 +425,8 @@ describe('DAO', function() {
Helpers.async(function(done) {
setTimeout(function() {
user.save().success(function() {
expect(updatedAt.getTime()).toBeLessThan(user.updatedAt.getTime())
done()
expect(updatedAt.getTime()).toBeLessThan(user.updatedAt.getTime())
done()
})
}, 10)
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!