Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHANGE] Create Orm alias decorator for MikroORM #1741

Closed
3 tasks done
Romakita opened this issue Jan 29, 2022 · 3 comments · Fixed by #1742 or #1746
Closed
3 tasks done

[CHANGE] Create Orm alias decorator for MikroORM #1741

Romakita opened this issue Jan 29, 2022 · 3 comments · Fixed by #1742 or #1746

Comments

@Romakita
Copy link
Collaborator

Romakita commented Jan 29, 2022

Information

  • Version: 6.x
  • Packages: @tsed/mikro-orm

The Mikro orm author suggest to change the @Connection decorator to another one. I suggest to create the Orm decorator to replace the Connection.

See mikro-orm/mikro-orm#2587

Example

import {Injectable, AfterRoutesInit} from "@tsed/common";
import {Connection} from "@tsed/mikro-orm";
import {MikroORM} from "@mikro-orm/core";

@Injectable()
export class UsersService {
-  @Connection()
+ @Orm() 
-  private readonly connection!: MikroORM;
+  private readonly orm!: MikroORM;

  async create(user: User): Promise<User> {

    // do something
    // ...
    // Then save
-    await this.connection.em.persistAndFlush(user);
+    await this.orm.em.persistAndFlush(user);
    console.log("Saved a new user with id: " + user.id);

    return user;
  }

  async find(): Promise<User[]> {
    const users = await this.orm.em.find(User, {});
    console.log("Loaded users: ", users);

    return users;
  }
}

Acceptance criteria

  • @Connection is deprecated with the Js doc comment: @deprecated Since 2022-02-01. Use Orm decorator instead.
  • @Orm decorator have the code implementation. Connection will just call the Orm one.
  • Documentation is up to date
@Romakita Romakita self-assigned this Jan 29, 2022
derevnjuk added a commit to derevnjuk/tsed that referenced this issue Jan 29, 2022
`@Connection()` decorator has been deprecated and replaced with new `@Orm()` to align API with MikroORM naming convention

closes tsedio#1741
derevnjuk added a commit to derevnjuk/tsed that referenced this issue Jan 29, 2022
derevnjuk added a commit to derevnjuk/tsed that referenced this issue Jan 29, 2022
`@Connection()` decorator has been deprecated and aliased with new `@Orm()` to align API with MikroORM naming convention

closes tsedio#1741
derevnjuk added a commit to derevnjuk/tsed that referenced this issue Jan 29, 2022
Romakita pushed a commit that referenced this issue Jan 29, 2022
`@Connection()` decorator has been deprecated and aliased with new `@Orm()` to align API with MikroORM naming convention

closes #1741
@Romakita
Copy link
Collaborator Author

🎉 This issue has been resolved in version 6.99.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

derevnjuk added a commit to derevnjuk/tsed that referenced this issue Jan 30, 2022
derevnjuk added a commit to derevnjuk/tsed that referenced this issue Jan 30, 2022
derevnjuk added a commit to derevnjuk/tsed that referenced this issue Jan 30, 2022
derevnjuk added a commit to derevnjuk/tsed that referenced this issue Jan 30, 2022
derevnjuk added a commit to derevnjuk/tsed that referenced this issue Jan 30, 2022
@Romakita
Copy link
Collaborator Author

🎉 This issue has been resolved in version 6.100.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Romakita
Copy link
Collaborator Author

🎉 This issue has been resolved in version 7.0.0-beta.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment