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 156c98ce
authored
Jun 14, 2014
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change the remaining spots of code to use the new promise.reduce syntax
1 parent
46c6e537
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
8 deletions
lib/dialects/sqlite/query-interface.js
lib/query-interface.js
lib/dialects/sqlite/query-interface.js
View file @
156c98c
...
@@ -32,10 +32,9 @@ var QueryInterface = module.exports = {
...
@@ -32,10 +32,9 @@ var QueryInterface = module.exports = {
var
sql
=
self
.
QueryGenerator
.
removeColumnQuery
(
tableName
,
fields
)
var
sql
=
self
.
QueryGenerator
.
removeColumnQuery
(
tableName
,
fields
)
,
subQueries
=
sql
.
split
(
';'
).
filter
(
function
(
q
)
{
return
q
!==
''
;
});
,
subQueries
=
sql
.
split
(
';'
).
filter
(
function
(
q
)
{
return
q
!==
''
;
});
subQueries
.
unshift
(
null
);
return
Utils
.
Promise
.
reduce
(
subQueries
,
function
(
total
,
subQuery
)
{
return
Utils
.
Promise
.
reduce
(
subQueries
,
function
(
total
,
subQuery
)
{
return
self
.
sequelize
.
query
(
subQuery
+
';'
,
null
,
{
raw
:
true
});
return
self
.
sequelize
.
query
(
subQuery
+
';'
,
null
,
{
raw
:
true
});
});
}
,
null
);
});
});
},
},
...
@@ -64,10 +63,9 @@ var QueryInterface = module.exports = {
...
@@ -64,10 +63,9 @@ var QueryInterface = module.exports = {
var
sql
=
self
.
QueryGenerator
.
removeColumnQuery
(
tableName
,
fields
)
var
sql
=
self
.
QueryGenerator
.
removeColumnQuery
(
tableName
,
fields
)
,
subQueries
=
sql
.
split
(
';'
).
filter
(
function
(
q
)
{
return
q
!==
''
;
});
,
subQueries
=
sql
.
split
(
';'
).
filter
(
function
(
q
)
{
return
q
!==
''
;
});
subQueries
.
unshift
(
null
);
return
Utils
.
Promise
.
reduce
(
subQueries
,
function
(
total
,
subQuery
)
{
return
Utils
.
Promise
.
reduce
(
subQueries
,
function
(
total
,
subQuery
)
{
return
self
.
sequelize
.
query
(
subQuery
+
';'
,
null
,
{
raw
:
true
});
return
self
.
sequelize
.
query
(
subQuery
+
';'
,
null
,
{
raw
:
true
});
});
}
,
null
);
});
});
},
},
...
@@ -96,10 +94,9 @@ var QueryInterface = module.exports = {
...
@@ -96,10 +94,9 @@ var QueryInterface = module.exports = {
var
sql
=
self
.
QueryGenerator
.
renameColumnQuery
(
tableName
,
attrNameBefore
,
attrNameAfter
,
fields
)
var
sql
=
self
.
QueryGenerator
.
renameColumnQuery
(
tableName
,
attrNameBefore
,
attrNameAfter
,
fields
)
,
subQueries
=
sql
.
split
(
';'
).
filter
(
function
(
q
)
{
return
q
!==
''
;
});
,
subQueries
=
sql
.
split
(
';'
).
filter
(
function
(
q
)
{
return
q
!==
''
;
});
subQueries
.
unshift
(
null
);
return
Utils
.
Promise
.
reduce
(
subQueries
,
function
(
total
,
subQuery
)
{
return
Utils
.
Promise
.
reduce
(
subQueries
,
function
(
total
,
subQuery
)
{
return
self
.
sequelize
.
query
(
subQuery
+
';'
,
null
,
{
raw
:
true
});
return
self
.
sequelize
.
query
(
subQuery
+
';'
,
null
,
{
raw
:
true
});
});
}
,
null
);
});
});
}
}
};
};
lib/query-interface.js
View file @
156c98c
...
@@ -192,13 +192,12 @@ module.exports = (function() {
...
@@ -192,13 +192,12 @@ module.exports = (function() {
options
=
options
||
{};
options
=
options
||
{};
var
dropAllTables
=
function
(
tableNames
)
{
var
dropAllTables
=
function
(
tableNames
)
{
tableNames
.
unshift
(
null
);
return
Utils
.
Promise
.
reduce
(
tableNames
,
function
(
total
,
tableName
)
{
return
Utils
.
Promise
.
reduce
(
tableNames
,
function
(
total
,
tableName
)
{
// if tableName is not in the Array of tables names then dont drop it
// if tableName is not in the Array of tables names then dont drop it
if
(
skip
.
indexOf
(
tableName
)
===
-
1
)
{
if
(
skip
.
indexOf
(
tableName
)
===
-
1
)
{
return
self
.
dropTable
(
tableName
,
{
cascade
:
true
});
return
self
.
dropTable
(
tableName
,
{
cascade
:
true
});
}
}
});
}
,
null
);
};
};
var
skip
=
options
.
skip
||
[];
var
skip
=
options
.
skip
||
[];
...
...
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