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 ba9e5e46
authored
Jun 29, 2012
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added options to specify whitelist when creating
1 parent
32e7f27d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
8 deletions
lib/dao-factory.js
lib/dao.js
spec-jasmine/dao.spec.js
lib/dao-factory.js
View file @
ba9e5e4
...
@@ -187,8 +187,8 @@ module.exports = (function() {
...
@@ -187,8 +187,8 @@ module.exports = (function() {
return
instance
return
instance
}
}
DAOFactory
.
prototype
.
create
=
function
(
values
)
{
DAOFactory
.
prototype
.
create
=
function
(
values
,
fields
)
{
return
this
.
build
(
values
).
save
()
return
this
.
build
(
values
).
save
(
fields
)
}
}
DAOFactory
.
prototype
.
__defineGetter__
(
'primaryKeys'
,
function
()
{
DAOFactory
.
prototype
.
__defineGetter__
(
'primaryKeys'
,
function
()
{
...
...
lib/dao.js
View file @
ba9e5e4
...
@@ -97,11 +97,14 @@ module.exports = (function() {
...
@@ -97,11 +97,14 @@ module.exports = (function() {
var
updatedAtAttr
=
this
.
__options
.
underscored
?
'updated_at'
:
'updatedAt'
var
updatedAtAttr
=
this
.
__options
.
underscored
?
'updated_at'
:
'updatedAt'
if
(
this
.
__options
.
timestamps
&&
this
.
hasOwnProperty
(
updatedAtAttr
))
if
(
this
.
__options
.
timestamps
&&
this
.
hasOwnProperty
(
updatedAtAttr
))
{
this
[
updatedAtAttr
]
=
new
Date
()
var
now
=
new
Date
()
this
[
updatedAtAttr
]
=
now
values
[
updatedAtAttr
]
=
now
}
if
(
this
.
isNewRecord
)
{
if
(
this
.
isNewRecord
)
{
return
this
.
QueryInterface
.
insert
(
this
,
this
.
__factory
.
tableName
,
this
.
values
)
return
this
.
QueryInterface
.
insert
(
this
,
this
.
__factory
.
tableName
,
values
)
}
else
{
}
else
{
var
identifier
=
this
.
__options
.
hasPrimaryKeys
?
this
.
primaryKeyValues
:
this
.
id
var
identifier
=
this
.
__options
.
hasPrimaryKeys
?
this
.
primaryKeyValues
:
this
.
id
,
tableName
=
this
.
__factory
.
tableName
,
tableName
=
this
.
__factory
.
tableName
...
...
spec-jasmine/dao.spec.js
View file @
ba9e5e4
...
@@ -411,7 +411,7 @@ describe('DAO', function() {
...
@@ -411,7 +411,7 @@ describe('DAO', function() {
var
now
=
Date
.
now
()
var
now
=
Date
.
now
()
,
user
=
null
,
user
=
null
,
updatedAt
=
null
,
updatedAt
=
null
Helpers
.
async
(
function
(
done
)
{
Helpers
.
async
(
function
(
done
)
{
// timeout is needed, in order to check the update of the timestamp
// timeout is needed, in order to check the update of the timestamp
setTimeout
(
function
()
{
setTimeout
(
function
()
{
...
@@ -425,8 +425,8 @@ describe('DAO', function() {
...
@@ -425,8 +425,8 @@ describe('DAO', function() {
Helpers
.
async
(
function
(
done
)
{
Helpers
.
async
(
function
(
done
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
user
.
save
().
success
(
function
()
{
user
.
save
().
success
(
function
()
{
expect
(
updatedAt
.
getTime
()).
toBeLessThan
(
user
.
updatedAt
.
getTime
())
expect
(
updatedAt
.
getTime
()).
toBeLessThan
(
user
.
updatedAt
.
getTime
())
done
()
done
()
})
})
},
10
)
},
10
)
})
})
...
...
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