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 f1e451e0
authored
Apr 26, 2020
by
Sushant
Committed by
GitHub
Apr 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: remove sequelize.import helper (#12175)
1 parent
541d2fac
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
58 deletions
docs/manual/other-topics/upgrade-to-v6.md
lib/sequelize.js
test/integration/sequelize.test.js
docs/manual/other-topics/upgrade-to-v6.md
View file @
f1e451e
...
@@ -20,9 +20,11 @@ You should now use [cls-hooked](https://github.com/Jeff-Lewis/cls-hooked) packag
...
@@ -20,9 +20,11 @@ You should now use [cls-hooked](https://github.com/Jeff-Lewis/cls-hooked) packag
Sequelize
.
useCLS
(
namespace
);
Sequelize
.
useCLS
(
namespace
);
```
```
###
Promis
e
###
Sequeliz
e
Bluebird has been removed. Public API now returns native promises.
`Sequelize.Promise`
is no longer available.
-
Bluebird has been removed. Public API now returns native promises.
-
`Sequelize.Promise`
is no longer available.
-
`sequelize.import`
method has been removed.
### Model
### Model
...
...
lib/sequelize.js
View file @
f1e451e
...
@@ -346,8 +346,6 @@ class Sequelize {
...
@@ -346,8 +346,6 @@ class Sequelize {
this
.
modelManager
=
new
ModelManager
(
this
);
this
.
modelManager
=
new
ModelManager
(
this
);
this
.
connectionManager
=
this
.
dialect
.
connectionManager
;
this
.
connectionManager
=
this
.
dialect
.
connectionManager
;
this
.
importCache
=
{};
Sequelize
.
runHooks
(
'afterInit'
,
this
);
Sequelize
.
runHooks
(
'afterInit'
,
this
);
}
}
...
@@ -463,38 +461,6 @@ class Sequelize {
...
@@ -463,38 +461,6 @@ class Sequelize {
}
}
/**
/**
* Imports a model defined in another file. Imported models are cached, so multiple
* calls to import with the same path will not load the file multiple times.
*
* @tutorial https://github.com/sequelize/express-example
*
* @param {string} importPath The path to the file that holds the model you want to import. If the part is relative, it will be resolved relatively to the calling file
*
* @returns {Model} Imported model, returned from cache if was already imported
*/
import
(
importPath
)
{
// is it a relative path?
if
(
path
.
normalize
(
importPath
)
!==
path
.
resolve
(
importPath
))
{
// make path relative to the caller
const
callerFilename
=
Utils
.
stack
()[
1
].
getFileName
();
const
callerPath
=
path
.
dirname
(
callerFilename
);
importPath
=
path
.
resolve
(
callerPath
,
importPath
);
}
if
(
!
this
.
importCache
[
importPath
])
{
let
defineCall
=
arguments
.
length
>
1
?
arguments
[
1
]
:
require
(
importPath
);
if
(
typeof
defineCall
===
'object'
)
{
// ES6 module compatibility
defineCall
=
defineCall
.
default
;
}
this
.
importCache
[
importPath
]
=
defineCall
(
this
,
DataTypes
);
}
return
this
.
importCache
[
importPath
];
}
/**
* Execute a query on the DB, optionally bypassing all the Sequelize goodness.
* Execute a query on the DB, optionally bypassing all the Sequelize goodness.
*
*
* By default, the function will return two arguments: an array of results, and a metadata object, containing number of affected rows etc.
* By default, the function will return two arguments: an array of results, and a metadata object, containing number of affected rows etc.
...
...
test/integration/sequelize.test.js
View file @
f1e451e
...
@@ -1224,28 +1224,6 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => {
...
@@ -1224,28 +1224,6 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => {
});
});
});
});
describe
(
'import'
,
()
=>
{
it
(
'imports a dao definition from a file absolute path'
,
function
()
{
const
Project
=
this
.
sequelize
.
import
(
'assets/project'
);
expect
(
Project
).
to
.
exist
;
});
it
(
'imports a dao definition with a default export'
,
function
()
{
const
Project
=
this
.
sequelize
.
import
(
'assets/es6project'
);
expect
(
Project
).
to
.
exist
;
});
it
(
'imports a dao definition from a function'
,
function
()
{
const
Project
=
this
.
sequelize
.
import
(
'Project'
,
(
sequelize
,
DataTypes
)
=>
{
return
sequelize
.
define
(
`Project
${
parseInt
(
Math
.
random
()
*
9999999999999999
,
10
)}
`
,
{
name
:
DataTypes
.
STRING
});
});
expect
(
Project
).
to
.
exist
;
});
});
describe
(
'define'
,
()
=>
{
describe
(
'define'
,
()
=>
{
it
(
'raises an error if no values are defined'
,
function
()
{
it
(
'raises an error if no values are defined'
,
function
()
{
expect
(()
=>
{
expect
(()
=>
{
...
...
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