docs: fix mikro-orm imports from framework (#13885)

This commit is contained in:
Shahed Nasser
2025-10-28 18:27:34 +02:00
committed by GitHub
parent 0244f029aa
commit 540ae996ff
22 changed files with 84 additions and 84 deletions
@@ -70,7 +70,7 @@ As of [Medusa v2.11.0](https://github.com/medusajs/medusa/releases/tag/v2.11.0),
</Note>
```ts
import { Migration } from "@medusajs/framework/@mikro-orm/migrations"
import { Migration } from "@medusajs/framework/mikro-orm/migrations"
export class Migration20241121103722 extends Migration {
@@ -44,7 +44,7 @@ As of [Medusa v2.11.0](https://github.com/medusajs/medusa/releases/tag/v2.11.0),
</Note>
```ts title="src/modules/blog/migrations/Migration202507021059_create_author.ts"
import { Migration } from "@medusajs/framework/@mikro-orm/migrations"
import { Migration } from "@medusajs/framework/mikro-orm/migrations"
export class Migration202507021059 extends Migration {
@@ -59,7 +59,7 @@ export class Migration202507021059 extends Migration {
}
```
The migration class in the file extends the `Migration` class imported from `@medusajs/framework/@mikro-orm/migrations`. In the `up` and `down` method of the migration class, you use the `addSql` method provided by MikroORM's `Migration` class to run PostgreSQL syntax.
The migration class in the file extends the `Migration` class imported from `@medusajs/framework/mikro-orm/migrations`. In the `up` and `down` method of the migration class, you use the `addSql` method provided by MikroORM's `Migration` class to run PostgreSQL syntax.
In the example above, the `up` method creates the table `author`, and the `down` method drops the table if the migration is reverted.
@@ -45,7 +45,7 @@ import {
MedusaContext,
} from "@medusajs/framework/utils"
import { Context } from "@medusajs/framework/types"
import { EntityManager } from "@medusajs/framework/@mikro-orm/knex"
import { EntityManager } from "@medusajs/framework/mikro-orm/knex"
class BlogModuleService {
// ...
@@ -72,7 +72,7 @@ class BlogModuleService {
You add two methods `getCount` and `getCountSql` that have the `InjectManager` decorator. Each of the methods also accept the `sharedContext` parameter which has the `MedusaContext` decorator.
The entity manager is injected to the `sharedContext.manager` property, which is an instance of [EntityManager from the `@medusajs/framework/@mikro-orm/knex` package](https://mikro-orm.io/api/knex/class/EntityManager).
The entity manager is injected to the `sharedContext.manager` property, which is an instance of [EntityManager from the `@medusajs/framework/mikro-orm/knex` package](https://mikro-orm.io/api/knex/class/EntityManager).
You use the manager in the `getCount` method to retrieve the number of records in a table, and in the `getCountSql` to run a PostgreSQL query that retrieves the count.
@@ -119,7 +119,7 @@ import {
MedusaContext,
} from "@medusajs/framework/utils"
import { Context } from "@medusajs/framework/types"
import { EntityManager } from "@medusajs/framework/@mikro-orm/knex"
import { EntityManager } from "@medusajs/framework/mikro-orm/knex"
class BlogModuleService {
// ...
@@ -180,7 +180,7 @@ import {
MedusaContext,
} from "@medusajs/framework/utils"
import { Context } from "@medusajs/framework/types"
import { EntityManager } from "@medusajs/framework/@mikro-orm/knex"
import { EntityManager } from "@medusajs/framework/mikro-orm/knex"
class BlogModuleService {
// ...
@@ -227,7 +227,7 @@ import {
MedusaContext,
} from "@medusajs/framework/utils"
import { Context } from "@medusajs/framework/types"
import { EntityManager } from "@medusajs/framework/@mikro-orm/knex"
import { EntityManager } from "@medusajs/framework/mikro-orm/knex"
class BlogModuleService {
// ...
@@ -386,7 +386,7 @@ import {
MedusaContext,
} from "@medusajs/framework/utils"
import { Context } from "@medusajs/framework/types"
import { EntityManager } from "@medusajs/framework/@mikro-orm/knex"
import { EntityManager } from "@medusajs/framework/mikro-orm/knex"
class BlogModuleService {
// ...
@@ -518,7 +518,7 @@ import {
MedusaContext,
} from "@medusajs/framework/utils"
import { Context } from "@medusajs/framework/types"
import { EntityManager } from "@medusajs/framework/@mikro-orm/knex"
import { EntityManager } from "@medusajs/framework/mikro-orm/knex"
class BlogModuleService {
// ...
@@ -588,7 +588,7 @@ The second parameter of the `baseRepository_.transaction` method is an object of
```ts highlights={[["24"]]}
// other imports...
import { EntityManager } from "@medusajs/framework/@mikro-orm/knex"
import { EntityManager } from "@medusajs/framework/mikro-orm/knex"
import {
InjectTransactionManager,
MedusaContext,
@@ -631,8 +631,8 @@ import {
MedusaContext,
} from "@medusajs/framework/utils"
import { Context } from "@medusajs/framework/types"
import { EntityManager } from "@medusajs/framework/@mikro-orm/knex"
import { IsolationLevel } from "@medusajs/framework/@mikro-orm/core"
import { EntityManager } from "@medusajs/framework/mikro-orm/knex"
import { IsolationLevel } from "@medusajs/framework/mikro-orm/core"
class BlogModuleService {
// ...
@@ -666,7 +666,7 @@ import {
MedusaContext,
} from "@medusajs/framework/utils"
import { Context } from "@medusajs/framework/types"
import { EntityManager } from "@medusajs/framework/@mikro-orm/knex"
import { EntityManager } from "@medusajs/framework/mikro-orm/knex"
class BlogModuleService {
// ...
@@ -202,7 +202,7 @@ As of [Medusa v2.11.0](https://github.com/medusajs/medusa/releases/tag/v2.11.0),
</Note>
```ts
import { Migration } from "@medusajs/framework/@mikro-orm/migrations"
import { Migration } from "@medusajs/framework/mikro-orm/migrations"
export class Migration20241121103722 extends Migration {