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

Commit 8e56e3a9 by sdepold

addColumnQuery

1 parent bca7b0de
......@@ -45,6 +45,18 @@ var QueryGenerator = module.exports = {
return Utils._.template(query)({ before: before, after: after })
},
addColumnQuery: function(tableName, attributes) {
var query = "ALTER TABLE `<%= tableName %>` ADD <%= attributes %>;"
, attrString = Utils._.map(attributes, function(definition, attributeName) {
return Utils._.template('`<%= attributeName %>` <%= definition %>')({
attributeName: attributeName,
definition: definition
})
}).join(', ')
return Utils._.template(query)({ tableName: tableName, attributes: attrString })
},
/*
Returns a query for selecting elements in the database <tableName>.
Options:
......
......@@ -79,6 +79,20 @@ module.exports = (function() {
},
/*
Returns a query, which adds an attribute to an existing table.
Parameters:
- tableName: Name of the existing table.
- attributeName: Name of the new attribute.
- options: A hash with attribute specific options:
- type: DataType
- defaultValue: A String with the default value
- allowNull: Boolean
*/
addColumnQuery: function(tableName, attributeName, options) {
throw new Error('Define the method addColumnQuery!')
},
/*
Takes something and transforms it into values of a where condition.
*/
getWhereConditions: function(smth) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!