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 fe8a1591
authored
Nov 04, 2013
by
Michael Schonfeld
Committed by
Michael Schonfeld
Jan 19, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create sum() finder example
1 parent
e44990e9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
examples/Sum/app.js
examples/Sum/app.js
0 → 100644
View file @
fe8a159
var
Sequelize
=
require
(
__dirname
+
"/../../index"
)
,
config
=
require
(
__dirname
+
"/../../spec/config/config"
)
,
sequelize
=
new
Sequelize
(
config
.
database
,
config
.
username
,
config
.
password
,
{
logging
:
false
})
var
Person
=
sequelize
.
define
(
'Person'
,
{
name
:
Sequelize
.
STRING
,
age
:
Sequelize
.
INTEGER
})
,
chainer
=
new
Sequelize
.
Utils
.
QueryChainer
sequelize
.
sync
({
force
:
true
}).
on
(
'success'
,
function
()
{
var
count
=
10
,
queries
=
[]
for
(
var
i
=
0
;
i
<
count
;
i
++
)
chainer
.
add
(
Person
.
create
({
name
:
'someone'
+
(
i
%
3
),
age
:
i
+
5
}))
console
.
log
(
"Begin to save "
+
count
+
" items!"
)
chainer
.
run
().
on
(
'success'
,
function
()
{
console
.
log
(
"finished"
)
Person
.
sum
(
'age'
).
on
(
'success'
,
function
(
sum
)
{
console
.
log
(
"Sum of all people's ages: "
+
sum
)
});
})
})
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