Fehler: 'createConnection'
is deprecated.ts(6387)
(alias) createConnection(options: DataSourceOptions): Promise<DataSource> (+2 overloads)
import createConnection
Creates a new connection and registers
it in the manager.
@deprecated
The
signature '(options: DataSourceOptions): Promise<DataSource>' of
'createConnection' is deprecated.ts(6387)
globals.d.ts(47,
4): The declaration was marked as deprecated here.
|
Fehlerhafter
Code:
import { Article } from "src/articles/entities/article.entity"
import { createConnection, DataSource } from "typeorm"
export const databaseProvider = [
{
provide: 'DATABASE_CONNECTION',
useFactory: async () => {
const connection=await createConnection({
|
Lösung:
CreateConnection
austauschen mit new DataSource
import { Article } from "src/articles/entities/article.entity"
import { createConnection, DataSource } from "typeorm"
export const databaseProvider = [
{
provide: 'DATABASE_CONNECTION',
useFactory: async () => {
const connection=await new DataSource({
type: 'postgres'
,
port: 5432,
host: 'localhost',
//host:'127.0.0.1',
database: 'ArticlesDB',
username: 'postgres',
password: 'root',
synchronize: true, //*in development:true //in production
FALSE !!
entities: ['dist/**/*.entity{.ts,.js}'],
//entities['Article'],
});
return connection;
}
}
];
|