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 6a36800f
authored
Dec 29, 2014
by
Thaddeus Quintin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added option passing back to the getTableName function.
1 parent
7895f286
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
lib/model.js
lib/model.js
View file @
6a36800
...
...
@@ -389,9 +389,9 @@ module.exports = (function() {
return
self
.
drop
(
options
);
}
}).
then
(
function
()
{
return
self
.
QueryInterface
.
createTable
(
self
.
getTableName
(),
attributes
,
options
);
return
self
.
QueryInterface
.
createTable
(
self
.
getTableName
(
options
),
attributes
,
options
);
}).
then
(
function
()
{
return
self
.
QueryInterface
.
showIndex
(
self
.
getTableName
(),
options
);
return
self
.
QueryInterface
.
showIndex
(
self
.
getTableName
(
options
),
options
);
}).
then
(
function
(
indexes
)
{
// Assign an auto-generated name to indexes which are not named by the user
self
.
options
.
indexes
=
self
.
QueryInterface
.
nameIndexes
(
self
.
options
.
indexes
,
self
.
tableName
);
...
...
@@ -403,7 +403,7 @@ module.exports = (function() {
});
return
Promise
.
map
(
indexes
,
function
(
index
)
{
return
self
.
QueryInterface
.
addIndex
(
self
.
getTableName
(),
index
.
fields
,
index
,
self
.
tableName
);
return
self
.
QueryInterface
.
addIndex
(
self
.
getTableName
(
options
),
index
.
fields
,
index
,
self
.
tableName
);
});
}).
return
(
this
);
};
...
...
@@ -415,7 +415,7 @@ module.exports = (function() {
* @return {Promise}
*/
Model
.
prototype
.
drop
=
function
(
options
)
{
return
this
.
QueryInterface
.
dropTable
(
this
.
getTableName
(),
options
);
return
this
.
QueryInterface
.
dropTable
(
this
.
getTableName
(
options
),
options
);
};
Model
.
prototype
.
dropSchema
=
function
(
schema
)
{
...
...
@@ -454,7 +454,7 @@ module.exports = (function() {
* @param {Object} options The hash of options from any query. You can use one model to access tables with matching schemas by overriding `getTableName` and using custom key/values to alter the name of the table. (eg. subscribers_1, subscribers_2)
* @return {String|Object}
*/
Model
.
prototype
.
getTableName
=
function
()
{
Model
.
prototype
.
getTableName
=
function
(
options
)
{
return
this
.
QueryGenerator
.
addSchema
(
this
);
};
...
...
@@ -676,7 +676,7 @@ module.exports = (function() {
var
hasJoin
=
false
,
tableNames
=
{
};
tableNames
[
this
.
getTableName
()]
=
true
;
tableNames
[
this
.
getTableName
(
options
)]
=
true
;
options
=
optClone
(
options
||
{});
options
=
Utils
.
_
.
defaults
(
options
,
{
...
...
@@ -725,7 +725,7 @@ module.exports = (function() {
return
this
.
runHooks
(
'beforeFindAfterOptions'
,
options
);
}
}).
then
(
function
()
{
return
this
.
QueryInterface
.
select
(
this
,
this
.
getTableName
(),
options
,
Utils
.
_
.
defaults
({
return
this
.
QueryInterface
.
select
(
this
,
this
.
getTableName
(
options
),
options
,
Utils
.
_
.
defaults
({
type
:
QueryTypes
.
SELECT
,
hasJoin
:
hasJoin
,
tableNames
:
Object
.
keys
(
tableNames
)
...
...
@@ -744,7 +744,7 @@ module.exports = (function() {
// whereCollection is used for non-primary key updates
this
.
options
.
whereCollection
=
options
.
where
||
null
;
return
this
.
QueryInterface
.
select
(
this
,
[[
this
.
getTableName
(),
this
.
name
],
joinTableName
],
options
,
Utils
.
_
.
defaults
({
return
this
.
QueryInterface
.
select
(
this
,
[[
this
.
getTableName
(
options
),
this
.
name
],
joinTableName
],
options
,
Utils
.
_
.
defaults
({
type
:
QueryTypes
.
SELECT
},
queryOptions
,
{
transaction
:
(
options
||
{}).
transaction
}));
};
...
...
@@ -817,7 +817,7 @@ module.exports = (function() {
options
=
paranoidClause
.
call
(
this
,
options
);
return
this
.
QueryInterface
.
rawSelect
(
this
.
getTableName
(),
options
,
aggregateFunction
,
this
);
return
this
.
QueryInterface
.
rawSelect
(
this
.
getTableName
(
options
),
options
,
aggregateFunction
,
this
);
};
/**
...
...
@@ -1214,7 +1214,7 @@ module.exports = (function() {
delete
values
[
this
.
primaryKeyField
];
}
return
this
.
QueryInterface
.
upsert
(
this
.
getTableName
(),
values
,
this
,
options
);
return
this
.
QueryInterface
.
upsert
(
this
.
getTableName
(
options
),
values
,
this
,
options
);
};
Model
.
prototype
.
insertOrUpdate
=
Model
.
prototype
.
upsert
;
...
...
@@ -1376,7 +1376,7 @@ module.exports = (function() {
}
// Insert all records at once
return
self
.
QueryInterface
.
bulkInsert
(
self
.
getTableName
(),
records
,
options
,
attributes
);
return
self
.
QueryInterface
.
bulkInsert
(
self
.
getTableName
(
options
),
records
,
options
,
attributes
);
}
}).
then
(
function
()
{
// Run after hook
...
...
@@ -1438,9 +1438,9 @@ module.exports = (function() {
if
(
self
.
_timestampAttributes
.
deletedAt
&&
!
options
.
force
)
{
var
attrValueHash
=
{};
attrValueHash
[
self
.
_timestampAttributes
.
deletedAt
]
=
Utils
.
now
(
self
.
modelManager
.
sequelize
.
options
.
dialect
);
return
self
.
QueryInterface
.
bulkUpdate
(
self
.
getTableName
(),
attrValueHash
,
options
.
where
,
options
,
self
.
rawAttributes
);
return
self
.
QueryInterface
.
bulkUpdate
(
self
.
getTableName
(
options
),
attrValueHash
,
options
.
where
,
options
,
self
.
rawAttributes
);
}
else
{
return
self
.
QueryInterface
.
bulkDelete
(
self
.
getTableName
(),
options
.
where
,
options
,
self
);
return
self
.
QueryInterface
.
bulkDelete
(
self
.
getTableName
(
options
),
options
.
where
,
options
,
self
);
}
}).
tap
(
function
()
{
// Run afterDestroy hook on each record individually
...
...
@@ -1507,7 +1507,7 @@ module.exports = (function() {
var
attrValueHash
=
{};
attrValueHash
[
self
.
_timestampAttributes
.
deletedAt
]
=
null
;
options
.
omitNull
=
false
;
return
self
.
QueryInterface
.
bulkUpdate
(
self
.
getTableName
(),
attrValueHash
,
options
.
where
,
options
,
self
.
_timestampAttributes
.
deletedAt
);
return
self
.
QueryInterface
.
bulkUpdate
(
self
.
getTableName
(
options
),
attrValueHash
,
options
.
where
,
options
,
self
.
_timestampAttributes
.
deletedAt
);
}).
tap
(
function
()
{
// Run afterDestroy hook on each record individually
if
(
options
.
individualHooks
)
{
...
...
@@ -1671,7 +1671,7 @@ module.exports = (function() {
mapFieldNames
.
call
(
self
,
options
,
self
);
// Run query to update all rows
return
self
.
QueryInterface
.
bulkUpdate
(
self
.
getTableName
(),
valuesUse
,
options
.
where
,
options
,
self
.
tableAttributes
).
then
(
function
(
affectedRows
)
{
return
self
.
QueryInterface
.
bulkUpdate
(
self
.
getTableName
(
options
),
valuesUse
,
options
.
where
,
options
,
self
.
tableAttributes
).
then
(
function
(
affectedRows
)
{
if
(
options
.
returning
)
{
daos
=
affectedRows
;
return
[
affectedRows
.
length
,
affectedRows
];
...
...
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