Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User
Error ;

Fehler: 'createConnection' is deprecated.ts(6387)

15.03.2023 (👁3040)


 

(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({

 

 

Ein Bild, das Text enthält.

Automatisch generierte Beschreibung

 

 

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;

        }

    }

];