i get error for import typeOrm

anyone know why my typeorm package is deprecated?

Connection, ConnectionOptions are deprecated, new names to use are: DataSource and DataSourceOptions. To create the same connection you had before use a new syntax: new DataSource({ /*...*/ }).
createConnection(), createConnections() are deprecated, since Connection is called DataSource now, to create a connection and connect to the database simply do:
server.ts
export const appDataSource = new DataSource({
// ... options
});
const main = async () => {
console.time('main');
await appDataSource.initialize();
};
main().catch(err => {
console.error(err);
process.exit(1);
});
user.resolver.ts
import { appDataSource } from '@server';
import { User } from '@entity/user.entity';
export class UserResolver {
userRepo = appDataSource.getRepository(User);
}
changelog: https://github.com/typeorm/typeorm/blob/master/CHANGELOG.md
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With