Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 8e56e3a9
authored
Dec 05, 2011
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addColumnQuery
1 parent
bca7b0de
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
lib/connectors/mysql/query-generator.js
lib/connectors/query-generator.js
lib/connectors/mysql/query-generator.js
View file @
8e56e3a
...
@@ -45,6 +45,18 @@ var QueryGenerator = module.exports = {
...
@@ -45,6 +45,18 @@ var QueryGenerator = module.exports = {
return
Utils
.
_
.
template
(
query
)({
before
:
before
,
after
:
after
})
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>.
Returns a query for selecting elements in the database <tableName>.
Options:
Options:
...
...
lib/connectors/query-generator.js
View file @
8e56e3a
...
@@ -79,6 +79,20 @@ module.exports = (function() {
...
@@ -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.
Takes something and transforms it into values of a where condition.
*/
*/
getWhereConditions
:
function
(
smth
)
{
getWhereConditions
:
function
(
smth
)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment