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 eeb453df
authored
Mar 30, 2011
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
just reverted getter idea for save, drop, etc.
1 parent
78d1f617
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
7 deletions
lib/sequelize/model-definition.js
lib/sequelize/model.js
test/Model/sync.js → test/Model/sync+drop.js
lib/sequelize/model-definition.js
View file @
eeb453d
...
...
@@ -34,15 +34,15 @@ ModelDefinition.prototype.sync = function(options) {
.
on
(
'failure'
,
function
()
{
self
.
emit
(
'failure'
,
self
)
})
}
if
(
options
.
force
)
this
.
drop
.
on
(
'success'
,
function
()
{
doQuery
()
})
if
(
options
.
force
)
this
.
drop
()
.
on
(
'success'
,
function
()
{
doQuery
()
})
else
doQuery
()
return
this
}
ModelDefinition
.
prototype
.
__defineGetter__
(
'drop'
,
function
()
{
ModelDefinition
.
prototype
.
drop
=
function
()
{
return
this
.
query
(
QueryGenerator
.
dropTableQuery
(
this
.
tableName
,
this
.
id
))
}
)
}
ModelDefinition
.
prototype
.
__defineGetter__
(
'all'
,
function
()
{
return
this
.
query
(
QueryGenerator
.
selectQuery
(
this
.
tableName
))
...
...
lib/sequelize/model.js
View file @
eeb453d
...
...
@@ -36,16 +36,16 @@ Model.prototype.query = function() {
return
s
.
query
.
apply
(
s
,
args
)
}
Model
.
prototype
.
__defineGetter__
(
'save'
,
function
()
{
Model
.
prototype
.
save
=
function
()
{
if
(
this
.
isNewRecord
)
return
this
.
query
(
QueryGenerator
.
insertQuery
(
this
.
definition
.
tableName
,
this
.
values
))
else
return
this
.
query
(
QueryGenerator
.
updateQuery
(
this
.
definition
.
tableName
,
this
.
values
,
this
.
id
))
}
)
}
Model
.
prototype
.
__defineGetter__
(
'destroy'
,
function
()
{
Model
.
prototype
.
destroy
=
function
()
{
return
this
.
query
(
QueryGenerator
.
deleteQuery
(
this
.
definition
.
tableName
,
this
.
id
))
}
)
}
Model
.
prototype
.
__defineGetter__
(
'isNewRecord'
,
function
()
{
return
this
.
id
==
null
...
...
test/Model/sync.js
→
test/Model/sync
+drop
.js
View file @
eeb453d
...
...
@@ -18,5 +18,12 @@ module.exports = {
bio
:
Sequelize
.
TEXT
})
User
.
sync
().
on
(
'failure'
,
beforeExit
)
},
'drop should work'
:
function
(
beforeExit
)
{
var
User
=
sequelize
.
define
(
'User'
,
{
name
:
Sequelize
.
STRING
,
bio
:
Sequelize
.
TEXT
})
User
.
drop
().
on
(
'success'
,
beforeExit
)
}
}
\ No newline at end of file
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