static async getConnection(): Promise<Connection> {
I would like to assign the connection in the bot instance so I don't need to create the connection each time, so I did:
bot.context.db = DatabaseProvider.getConnection().then((conn) => { return conn; });
but I get:
Type 'Promise<Connection>' is missing the following properties from type 'Connection': name, options, isConnected, driver, and 32 more.
this is weird 'cause when I instantiated the bot I did:
const bot = new Telegraf<TelegrafContext>(BOT_TOKEN);
when TelegrafContext is a .d.ts:
import type { Context, Stage } from 'telegraf';
import type { I18n } from 'telegraf-i18n';
import type { Connection } from 'typeorm';
export interface TelegrafContext extends Context {
db: Connection
i18n: I18n
scene: Stage
}
what is wrong?
Promise<Connection> is not the same as Connection
Обсуждают сегодня