forked from nextauthjs/next-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(adapters): update
typeorm
support (nextauthjs#4844)
We haven't kept up with the recent TypeORM changes, and since they are still <1, it's likely that users kept upgrading, even if there were breaking changes. BREAKING CHANGE: [`typeorm`](https://github.com/typeorm/typeorm) is still in active development and has not yet published a stable release. Because of this, you can expect breaking changes in minor versions. This release of the adapter expects `[email protected]` and is not validated against previous or future releases. Run `npm i typeorm@latest` and make sure to read the [release notes](https://github.com/typeorm/typeorm/releases) for breaking changes in TypeORM
- Loading branch information
1 parent
c1f7ce3
commit 88ad25a
Showing
12 changed files
with
242 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,18 +5,22 @@ title: TypeORM | |
|
||
# TypeORM | ||
|
||
This Adapter is used to support SQL-flavored databases (like SQLite, MySQL, MSSQL, MariaDB, CockroachDB, etc.) through [TypeORM](https://typeorm.io), and mostly kept around for legacy reasons. (See the warning below.) | ||
This Adapter is used to support SQL-flavored databases (like SQLite, MySQL, MSSQL, MariaDB, CockroachDB, etc.) through [TypeORM](https://typeorm.io). | ||
|
||
:::note | ||
If you previously used this Adapter with MongoDB, check out the [MongoDB Adapter](/adapters/mongodb) instead. | ||
::: | ||
|
||
:::warning | ||
:::note | ||
In the future, we might split up this adapter to support single flavors of SQL for easier maintenance and reduced bundle size. | ||
::: | ||
|
||
## Usage | ||
|
||
:::warning | ||
[`typeorm`](https://github.com/typeorm/typeorm) is still in active development and has not yet published a stable release. Because of this, you can expect breaking changes in minor versions. This adapter expects `[email protected]` and is not validated against previous or future releases. | ||
::: | ||
|
||
To use this Adapter, you need to install the following packages: | ||
|
||
```bash npm2yarn2pnpm | ||
|
@@ -36,7 +40,7 @@ export default NextAuth({ | |
}) | ||
``` | ||
|
||
`TypeORMLegacyAdapter` takes either a connection string, or a [`ConnectionOptions`](https://github.com/typeorm/typeorm/blob/master/docs/connection-options.md) object as its first parameter. | ||
`TypeORMLegacyAdapter` takes either a connection string, or a [`DataSourceOptions`](https://github.com/typeorm/typeorm/blob/master/docs/data-source-options.md) object as its first parameter. | ||
|
||
## Custom models | ||
|
||
|
@@ -217,20 +221,17 @@ For example, you can add the naming convention option to the connection object i | |
import NextAuth from "next-auth" | ||
import { TypeORMLegacyAdapter } from "@next-auth/typeorm-legacy-adapter" | ||
import { SnakeNamingStrategy } from 'typeorm-naming-strategies' | ||
import { ConnectionOptions } from "typeorm" | ||
|
||
const connection: ConnectionOptions = { | ||
export default NextAuth({ | ||
adapter: TypeORMLegacyAdapter({ | ||
type: "mysql", | ||
host: "localhost", | ||
port: 3306, | ||
username: "test", | ||
password: "test", | ||
database: "test", | ||
namingStrategy: new SnakeNamingStrategy() | ||
} | ||
|
||
export default NextAuth({ | ||
adapter: TypeORMLegacyAdapter(connection), | ||
}), | ||
... | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.