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 d28d1d57
authored
Aug 23, 2010
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added method for importing models from a file
1 parent
7769ee65
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
14 deletions
src/Sequelize.js
src/Sequelize.js
View file @
d28d1d5
...
@@ -72,6 +72,36 @@ var classMethods = {
...
@@ -72,6 +72,36 @@ var classMethods = {
}
}
Sequelize
.
prototype
=
{
Sequelize
.
prototype
=
{
define
:
function
(
name
,
attributes
,
options
)
{
var
SequelizeTable
=
require
(
__dirname
+
"/SequelizeTable"
).
SequelizeTable
attributes
.
createdAt
=
'DATETIME NOT NULL'
attributes
.
updatedAt
=
'DATETIME NOT NULL'
var
table
=
new
SequelizeTable
(
Sequelize
,
this
,
Sequelize
.
Helper
.
SQL
.
asTableName
(
name
),
attributes
,
options
)
table
.
attributes
=
attributes
this
.
tables
[
name
]
=
{
klass
:
table
,
attributes
:
attributes
}
table
.
sequelize
=
this
return
table
},
import
:
function
(
path
)
{
var
imported
=
require
(
path
),
self
=
this
,
result
=
{}
Sequelize
.
Helper
.
Hash
.
forEach
(
imported
,
function
(
definition
,
functionName
)
{
definition
(
Sequelize
,
self
)
})
Sequelize
.
Helper
.
Hash
.
forEach
(
this
.
tables
,
function
(
constructor
,
name
)
{
result
[
name
]
=
constructor
.
klass
})
return
result
},
get
tableNames
()
{
get
tableNames
()
{
var
result
=
[]
var
result
=
[]
Sequelize
.
Helper
.
Hash
.
keys
(
this
.
tables
).
forEach
(
function
(
tableName
)
{
Sequelize
.
Helper
.
Hash
.
keys
(
this
.
tables
).
forEach
(
function
(
tableName
)
{
...
@@ -115,20 +145,6 @@ Sequelize.prototype = {
...
@@ -115,20 +145,6 @@ Sequelize.prototype = {
})
})
},
},
define
:
function
(
name
,
attributes
,
options
)
{
var
SequelizeTable
=
require
(
__dirname
+
"/SequelizeTable"
).
SequelizeTable
attributes
.
createdAt
=
'DATETIME NOT NULL'
attributes
.
updatedAt
=
'DATETIME NOT NULL'
var
table
=
new
SequelizeTable
(
Sequelize
,
this
,
Sequelize
.
Helper
.
SQL
.
asTableName
(
name
),
attributes
,
options
)
table
.
attributes
=
attributes
this
.
tables
[
name
]
=
{
klass
:
table
,
attributes
:
attributes
}
table
.
sequelize
=
this
return
table
},
query
:
function
(
queryString
,
callback
)
{
query
:
function
(
queryString
,
callback
)
{
var
fields
=
[]
var
fields
=
[]
var
values
=
[]
var
values
=
[]
...
...
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