No metadata for “User” was found.
EntityMetadataNotFoundError: No metadata for “User” was found.
TypeORM 官方的例程连接SQL server时候有很多错误
查了很多资料没有结果。
import { DataSource } from 'typeorm';
export const databaseProviders = [
{
provide: 'DATA_SOURCE',
useFactory: async () => {
const dataSource = new DataSource({
type: 'mssql',
host: 'localhost',
port: 1433,
username: 'sa',
password: '123456',
database: 'test',
entities: [
**__dirname + '/../**/*.entity{.ts,.js}',**
],
synchronize: true,
});
return dataSource.initialize();
},
},
];
后来连接到Git TypeORM 示例对比发现 entities 路径问题
__dirname + '/…//.entity{.ts,.js}',,魔术路径总是不那么正确
后来使用TypeORM示例中
)
【post]==>【User]* 会自动引入路径,后连接数据库,操作更新无故障。
这个真是查了很长时间