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 fe91e41c
authored
Nov 07, 2011
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
skeleton for query-generator
1 parent
39fbc9c8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
1 deletions
lib/connectors/query-generator.js
lib/sequelize.js
lib/connectors/query-generator.js
0 → 100644
View file @
fe91e41
var
QueryGenerator
=
module
.
exports
=
{
/*
Returns a query for creating a table.
Attributes should have the format: {attributeName: type, attr2: type2} --> {title: 'VARCHAR(255)'}
*/
createTableQuery
:
function
(
tableName
,
attributes
,
options
)
{
throw
new
Error
(
'Define the method createTableQuery!'
)
},
/*
Returns a query for dropping a table.
*/
dropTableQuery
:
function
(
tableName
,
options
)
{
throw
new
Error
(
'Define the method dropTableQuery!'
)
},
/*
Returns a query for selecting elements in the table <tableName>.
Options:
- attributes -> An array of attributes (e.g. ['name', 'birthday']). Default: *
- where -> A hash with conditions (e.g. {name: 'foo'})
OR an ID as integer
OR a string with conditions (e.g. 'name="foo"').
If you use a string, you have to escape it on your own.
- order -> e.g. 'id DESC'
- group
- limit -> The maximum count you want to get.
- offset -> An offset value to start from. Only useable with limit!
*/
selectQuery
:
function
(
tableName
,
options
)
{
throw
new
Error
(
'Define the method selectQuery!'
)
},
/*
Returns a query for counting elements in the table <tableName>.
Options are the very same as in selectQuery.
*/
countQuery
:
function
(
tableName
,
options
)
{
throw
new
Error
(
'Define the method countQuery!'
)
},
/*
Returns a query for getting the max value of a field in the table <tableName>.
Options are the very same as in selectQuery.
*/
maxQuery
:
function
(
tableName
,
field
,
options
)
{
throw
new
Error
(
'Define the method maxQuery!'
)
},
/*
Returns a query for getting the min value of a field in the table <tableName>.
Options are the very same as in selectQuery.
*/
minQuery
:
function
(
tableName
,
field
,
options
)
{
throw
new
Error
(
'Define the method minQuery!'
)
},
/*
Returns an insert into command. Parameters: table name + hash of attribute-value-pairs.
*/
insertQuery
:
function
(
tableName
,
attrValueHash
)
{
throw
new
Error
(
'Define the method insertQuery!'
)
},
/*
Returns an update query.
Parameters:
- tableName -> Name of the table
- values -> A hash with attribute-value-pairs
- where -> A hash with conditions (e.g. {name: 'foo'})
OR an ID as integer
OR a string with conditions (e.g. 'name="foo"').
If you use a string, you have to escape it on your own.
*/
updateQuery
:
function
(
tableName
,
values
,
where
)
{
throw
new
Error
(
'Define the method updateQuery!'
)
},
/*
Returns a deletion query.
Parameters:
- tableName -> Name of the table
- where -> A hash with conditions (e.g. {name: 'foo'})
OR an ID as integer
OR a string with conditions (e.g. 'name="foo"').
If you use a string, you have to escape it on your own.
Options:
- limit -> Maximaum count of lines to delete
*/
deleteQuery
:
function
(
tableName
,
where
,
options
)
{
throw
new
Error
(
'Define the method deleteQuery!'
)
},
/*
Takes something and transforms it into values of a where condition.
*/
getWhereConditions
:
function
(
smth
)
{
throw
new
Error
(
'Define the method getWhereConditions!'
)
},
/*
Takes a hash and transforms it into a mysql where condition: {key: value, key2: value2} ==> key=value AND key2=value2
The values are transformed by the relevant datatype.
*/
hashToWhereConditions
:
function
(
hash
)
{
throw
new
Error
(
'Define the method hashToWhereConditions!'
)
}
}
lib/sequelize.js
View file @
fe91e41
...
@@ -19,7 +19,7 @@ var Sequelize = module.exports = function(database, username, password, options)
...
@@ -19,7 +19,7 @@ var Sequelize = module.exports = function(database, username, password, options)
port
:
options
.
port
||
3306
port
:
options
.
port
||
3306
}
}
var
ConnectorManager
=
require
(
"./connectors/"
+
(
options
.
connector
||
'mysql'
)
+
"/connector-manager"
)
var
ConnectorManager
=
require
(
"./connectors/"
+
(
this
.
options
.
connector
||
'mysql'
)
+
"/connector-manager"
)
this
.
modelManager
=
new
ModelManager
(
this
)
this
.
modelManager
=
new
ModelManager
(
this
)
this
.
connectorManager
=
new
ConnectorManager
(
this
.
config
)
this
.
connectorManager
=
new
ConnectorManager
(
this
.
config
)
...
...
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