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

Commit ba9e5e46 by Jan Aagaard Meier

added options to specify whitelist when creating

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