【发布时间】:2022-07-11 07:12:18
【问题描述】:
在 typeORM 文档中,可以根据 https://github.com/typeorm/typeorm/blob/master/docs/data-source-options.md 将 cli 参数添加到 DataSourceOptions。我在https://typeorm.io/using-cli 上看到的例子是
{
cli: {
entitiesDir: "src/entity",
subscribersDir: "src/subscriber",
migrationsDir: "src/migration"
}
}
我在我的代码中尝试如下:
let dataSource = new DataSource(
{
type: 'postgres',
host: 'localhost',
port: 5432,
database: 'website',
username: 'test',
password: 'test',
logging: true,
synchronize: false,
entities: [User, Posts],
cli: {
entitiesDir: "src/entity",
subscribersDir: "src/subscriber",
migrationsDir: "src/migration"
}
})
但是我收到以下错误:
'{ type: "postgres"; host: string; port: number; database: string; username: string; password: string; logging: true; synchronize: false; entities: (typeof User | typeof Wallet)[]; cli: { entitiesDir: string; subscribersDir: string; migrationsDir: string; }; }' 类型的参数不能分配给 'DataSourceOptions' 类型的参数。
对象字面量只能指定已知属性,'cli' 类型中不存在'PostgresConnectionOptions'.ts(2345)
【问题讨论】:
标签: javascript typescript typeorm