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

This commit is contained in:
Shahed Nasser authored and GitHub committed 2025-10-28 18:27:34 +02:00
1 parent 0244f029aa
commit 540ae996ff
22 files changed
+84 -84

No files matched your search

+20 -20
View File
@@ -6367,7 +6367,7 @@ Next, create the `integration-tests/setup.js` file with the following content:
As of [Medusa v2.11.0](https://github.com/medusajs/medusa/releases/tag/v2.11.0), MikroORM dependencies are included in the `@medusajs/framework` package. If you're using an older version of Medusa, change the require statement to `@mikro-orm/core`.
```js title="integration-tests/setup.js"
const { MetadataStorage } = require("@medusajs/framework/@mikro-orm/core")
const { MetadataStorage } = require("@medusajs/framework/mikro-orm/core")
MetadataStorage.clear()
```
@@ -11549,7 +11549,7 @@ The `db:generate` command of the Medusa CLI accepts one or more module names to
As of [Medusa v2.11.0](https://github.com/medusajs/medusa/releases/tag/v2.11.0), MikroORM dependencies are included in the `@medusajs/framework` package. If you're using an older version of Medusa, change the import statement to `@mikro-orm/migrations`.
```ts
import { Migration } from "@medusajs/framework/@mikro-orm/migrations"
import { Migration } from "@medusajs/framework/mikro-orm/migrations"
export class Migration20241121103722 extends Migration {
@@ -12320,7 +12320,7 @@ For example:
As of [Medusa v2.11.0](https://github.com/medusajs/medusa/releases/tag/v2.11.0), MikroORM dependencies are included in the `@medusajs/framework` package. If you're using an older version of Medusa, change the import statement to `@mikro-orm/migrations`.
```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 {
@@ -12335,7 +12335,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.
@@ -17667,7 +17667,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 {
// ...
@@ -17694,7 +17694,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.
@@ -17731,7 +17731,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 {
// ...
@@ -17788,7 +17788,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 {
// ...
@@ -17831,7 +17831,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 {
// ...
@@ -17964,7 +17964,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 {
// ...
@@ -18079,7 +18079,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 {
// ...
@@ -18145,7 +18145,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,
@@ -18188,8 +18188,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 {
// ...
@@ -18223,7 +18223,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 {
// ...
@@ -19289,7 +19289,7 @@ The `db:generate` command of the Medusa CLI accepts one or more module names to
As of [Medusa v2.11.0](https://github.com/medusajs/medusa/releases/tag/v2.11.0), MikroORM dependencies are included in the `@medusajs/framework` package. If you're using an older version of Medusa, change the import statement to `@mikro-orm/migrations`.
```ts
import { Migration } from "@medusajs/framework/@mikro-orm/migrations"
import { Migration } from "@medusajs/framework/mikro-orm/migrations"
export class Migration20241121103722 extends Migration {
@@ -56054,7 +56054,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 {
// ...
@@ -80266,7 +80266,7 @@ In `src/modules/product-review/service.ts`, add the following methods to the `Pr
import { InjectManager, MedusaService, MedusaContext } from "@medusajs/framework/utils"
import Review from "./models/review"
import { Context } from "@medusajs/framework/types"
import { EntityManager } from "@medusajs/framework/@mikro-orm/knex"
import { EntityManager } from "@medusajs/framework/mikro-orm/knex"
class ProductReviewModuleService extends MedusaService({
Review,
@@ -102246,7 +102246,7 @@ In `src/modules/wishlist/service.ts`, add the following imports and method:
// other imports...
import { InjectManager } 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"
export default class WishlistModuleService extends MedusaService({
Wishlist,
@@ -121204,7 +121204,7 @@ Before adding the step that does this, you'll add a method in the `RestockModule
// other imports...
import { InjectManager, 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 RestockModuleService extends MedusaService({
RestockSubscription,