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 77c55541
authored
Nov 10, 2011
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addAttribute is public
1 parent
82719d59
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
10 deletions
lib/model-factory.js
lib/model.js
lib/model-factory.js
View file @
77c5554
...
...
@@ -121,7 +121,6 @@ ModelFactory.prototype.build = function(values, options) {
options
=
options
||
{}
instance
.
__definition
=
this
//console.log(this.attributes)
Utils
.
_
.
map
(
this
.
attributes
,
function
(
definition
,
name
)
{
if
(
typeof
instance
[
name
]
==
'undefined'
)
{
var
value
=
null
...
...
@@ -130,7 +129,7 @@ ModelFactory.prototype.build = function(values, options) {
value
=
self
.
rawAttributes
[
name
].
defaultValue
instance
[
name
]
=
value
instance
.
__
addAttribute
(
name
,
value
)
instance
.
addAttribute
(
name
,
value
)
}
})
Utils
.
_
.
each
(
this
.
options
.
instanceMethods
||
{},
function
(
fct
,
name
)
{
instance
[
name
]
=
fct
})
...
...
lib/model.js
View file @
77c5554
...
...
@@ -141,13 +141,18 @@ module.exports = (function() {
return
result
}
Model
.
prototype
.
addAttribute
=
function
(
attribute
,
value
)
{
this
[
attribute
]
=
value
this
.
attributes
.
push
(
attribute
)
}
// private
var
initAttributes
=
function
(
values
)
{
var
self
=
this
// add all passed values to the model and store the attribute names in this.attributes
Utils
.
_
.
map
(
values
,
function
(
value
,
key
)
{
self
.
__
addAttribute
(
key
,
value
)
})
Utils
.
_
.
map
(
values
,
function
(
value
,
key
)
{
self
.
addAttribute
(
key
,
value
)
})
// set id to null if not passed as value
// a newly created model has no id
...
...
@@ -163,7 +168,7 @@ module.exports = (function() {
Utils
.
_
.
map
(
defaults
,
function
(
value
,
attr
)
{
if
(
!
self
.
hasOwnProperty
(
attr
))
self
.
__
addAttribute
(
attr
,
value
)
self
.
addAttribute
(
attr
,
value
)
})
}
...
...
@@ -175,12 +180,6 @@ module.exports = (function() {
return
s
.
query
.
apply
(
s
,
args
)
}
Model
.
prototype
.
__addAttribute
=
function
(
attribute
,
value
)
{
this
[
attribute
]
=
value
this
.
attributes
.
push
(
attribute
)
}
/* Add the instance methods to Model */
Utils
.
_
.
extend
(
Model
.
prototype
,
Mixin
.
prototype
)
...
...
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