docs: fix mikro-orm imports from framework (#13885)
This commit is contained in:
1 parent
0244f029aa
commit
540ae996ff
22 files changed
+84
-84
No files matched your search
@@ -70,7 +70,7 @@ As of [Medusa v2.11.0](https://github.com/medusajs/medusa/releases/tag/v2.11.0),
|
||||
</Note>
|
||||
|
||||
```js title="integration-tests/setup.js"
|
||||
const { MetadataStorage } = require("@medusajs/framework/@mikro-orm/core")
|
||||
const { MetadataStorage } = require("@medusajs/framework/mikro-orm/core")
|
||||
|
||||
MetadataStorage.clear()
|
||||
```
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ export const generatedEditDates = {
|
||||
"app/learn/fundamentals/workflows/execute-another-workflow/page.mdx": "2025-08-01T07:28:51.036Z",
|
||||
"app/learn/fundamentals/modules/loaders/page.mdx": "2025-10-09T11:41:31.724Z",
|
||||
"app/learn/fundamentals/admin/widgets/page.mdx": "2025-07-25T15:08:07.035Z",
|
||||
"app/learn/fundamentals/data-models/page.mdx": "2025-10-09T11:39:30.944Z",
|
||||
"app/learn/fundamentals/data-models/page.mdx": "2025-10-28T16:01:48.099Z",
|
||||
"app/learn/fundamentals/modules/remote-link/page.mdx": "2024-09-30T08:43:53.127Z",
|
||||
"app/learn/fundamentals/api-routes/protected-routes/page.mdx": "2025-06-19T16:04:36.064Z",
|
||||
"app/learn/fundamentals/workflows/add-workflow-hook/page.mdx": "2025-07-18T11:33:15.959Z",
|
||||
@@ -32,7 +32,7 @@ export const generatedEditDates = {
|
||||
"app/learn/fundamentals/admin/page.mdx": "2025-07-25T12:46:15.466Z",
|
||||
"app/learn/fundamentals/workflows/long-running-workflow/page.mdx": "2025-08-01T07:16:21.736Z",
|
||||
"app/learn/fundamentals/workflows/constructor-constraints/page.mdx": "2025-08-01T13:11:18.823Z",
|
||||
"app/learn/fundamentals/data-models/write-migration/page.mdx": "2025-10-09T11:39:07.940Z",
|
||||
"app/learn/fundamentals/data-models/write-migration/page.mdx": "2025-10-28T16:01:36.609Z",
|
||||
"app/learn/fundamentals/data-models/manage-relationships/page.mdx": "2025-04-25T14:16:41.124Z",
|
||||
"app/learn/fundamentals/modules/remote-query/page.mdx": "2024-07-21T21:20:24+02:00",
|
||||
"app/learn/fundamentals/modules/options/page.mdx": "2025-03-18T15:12:34.510Z",
|
||||
@@ -53,7 +53,7 @@ export const generatedEditDates = {
|
||||
"app/learn/debugging-and-testing/testing-tools/integration-tests/api-routes/page.mdx": "2025-09-02T08:36:12.714Z",
|
||||
"app/learn/debugging-and-testing/testing-tools/integration-tests/page.mdx": "2024-12-09T15:52:01.019Z",
|
||||
"app/learn/debugging-and-testing/testing-tools/integration-tests/workflows/page.mdx": "2025-07-30T13:43:44.636Z",
|
||||
"app/learn/debugging-and-testing/testing-tools/page.mdx": "2025-10-09T11:38:33.099Z",
|
||||
"app/learn/debugging-and-testing/testing-tools/page.mdx": "2025-10-28T16:01:29.630Z",
|
||||
"app/learn/debugging-and-testing/testing-tools/unit-tests/module-example/page.mdx": "2024-09-02T11:04:27.232Z",
|
||||
"app/learn/debugging-and-testing/testing-tools/unit-tests/page.mdx": "2024-09-02T11:03:26.997Z",
|
||||
"app/learn/fundamentals/modules/service-constraints/page.mdx": "2025-03-18T15:12:46.006Z",
|
||||
@@ -66,9 +66,9 @@ export const generatedEditDates = {
|
||||
"app/learn/fundamentals/module-links/directions/page.mdx": "2025-03-17T12:52:06.161Z",
|
||||
"app/learn/fundamentals/module-links/page.mdx": "2025-04-17T08:50:17.036Z",
|
||||
"app/learn/fundamentals/module-links/query/page.mdx": "2025-10-27T09:30:26.957Z",
|
||||
"app/learn/fundamentals/modules/db-operations/page.mdx": "2025-10-09T11:43:28.746Z",
|
||||
"app/learn/fundamentals/modules/db-operations/page.mdx": "2025-10-28T16:02:06.265Z",
|
||||
"app/learn/fundamentals/modules/multiple-services/page.mdx": "2025-03-18T15:11:44.632Z",
|
||||
"app/learn/fundamentals/modules/page.mdx": "2025-10-09T11:41:57.515Z",
|
||||
"app/learn/fundamentals/modules/page.mdx": "2025-10-28T16:02:08.857Z",
|
||||
"app/learn/debugging-and-testing/instrumentation/page.mdx": "2025-10-09T11:37:32.815Z",
|
||||
"app/learn/fundamentals/api-routes/additional-data/page.mdx": "2025-04-17T08:50:17.036Z",
|
||||
"app/learn/fundamentals/workflows/variable-manipulation/page.mdx": "2025-04-24T13:14:43.967Z",
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user