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

Commit a9ceb217 by Sascha Depold

save passed options without database config

1 parent 476474bd
...@@ -141,6 +141,14 @@ exports.Helper = function(Sequelize) { ...@@ -141,6 +141,14 @@ exports.Helper = function(Sequelize) {
target[key] = value target[key] = value
}) })
return target return target
},
without: function(object, withoutKeys) {
var result = {}
Helper.Hash.forEach(object, function(value, key) {
if(withoutKeys.indexOf(key) == -1)
result[key] = value
})
return result
} }
}, },
Array: { Array: {
......
...@@ -8,7 +8,7 @@ var Sequelize = function(database, username, password, options) { ...@@ -8,7 +8,7 @@ var Sequelize = function(database, username, password, options) {
port : options.port || 3306 port : options.port || 3306
} }
this.tables = {} this.tables = {}
this.options = options this.options = Sequelize.Helper.Hash.without(options, ["host", "port"])
} }
var classMethods = { var classMethods = {
......
...@@ -101,5 +101,9 @@ module.exports = { ...@@ -101,5 +101,9 @@ module.exports = {
}, },
'Inflection: should be available': function(assert) { 'Inflection: should be available': function(assert) {
assert.isDefined(h.Inflection) assert.isDefined(h.Inflection)
},
'Hash: without': function(assert) {
var hash = {a: 1, b: 2}
assert.eql(h.Hash.without(hash, ["a"]), {b: 2})
} }
} }
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!