首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不能指定键入Knex。

不能指定键入Knex。
EN

Stack Overflow用户
提问于 2022-03-26 13:57:40
回答 1查看 416关注 0票数 0

我是一个不知道怎么做的新手,Knes有两个变量名,我应该如何获得返回我想要的变量的方法。

import {knex, Knex} from 'knex'

'migrations'}}const createConnection():承诺{const config: Knex.Config = {client:'mysql',连接:{主机: this.config.host,端口: this.config.port,用户: this.config.user,密码: this.config.password,数据库:host.config.database},调试: this.config.debug,迁移:{tableName: createConnection db =k奈(Config)`

代码语言:javascript
复制
    await db.raw('select 1');
    return db;
}`

上述代码webstorm报告了一个错误。

EN

回答 1

Stack Overflow用户

发布于 2022-03-27 02:20:58

代码语言:javascript
复制
 public async createConnection(): Promise<Knex> {
        const config: Knex.Config = {
            client: 'mysql',
            connection: {
                host: this.config.host,
                port: this.config.port,
                user: this.config.user,
                password: this.config.password,
                database: this.config.database
            },
            debug: this.config.debug,
            migrations: {
                tableName: 'migrations'
            }
        }
        const db: Knex = knex(config)

        await db.raw('select 1');

        return db;
  
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71628676

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档