docs: add guide on how to seed data (#9449)

Add a guide on how to seed data using a custom CLI script, with an example to seed products

Closes DOCS-953
This commit is contained in:
Shahed Nasser
2024-10-14 07:08:05 +00:00
committed by GitHub
parent c9ce918982
commit e3dc9eaf0c
6 changed files with 241 additions and 27 deletions
@@ -36,7 +36,7 @@ export const methodsHighlight = [
// other imports...
import {
InjectManager,
MedusaContext
MedusaContext,
} from "@medusajs/framework/utils"
class HelloModuleService {
@@ -99,7 +99,7 @@ export const opHighlights = [
import {
InjectManager,
InjectTransactionManager,
MedusaContext
MedusaContext,
} from "@medusajs/framework/utils"
import { Context } from "@medusajs/framework/types"
import { EntityManager } from "@mikro-orm/knex"
@@ -118,10 +118,10 @@ class HelloModuleService {
await transactionManager.nativeUpdate(
"my_custom",
{
id: input.id
id: input.id,
},
{
name: input.name
name: input.name,
}
)
@@ -307,7 +307,7 @@ export const repoHighlights = [
import {
InjectManager,
InjectTransactionManager,
MedusaContext
MedusaContext,
} from "@medusajs/framework/utils"
import { Context } from "@medusajs/framework/types"
import { EntityManager } from "@mikro-orm/knex"
@@ -327,10 +327,10 @@ class HelloModuleService {
await transactionManager.nativeUpdate(
"my_custom",
{
id: input.id
id: input.id,
},
{
name: input.name
name: input.name,
}
)
@@ -342,7 +342,7 @@ class HelloModuleService {
return updatedRecord
},
{
transaction: sharedContext.transactionManager
transaction: sharedContext.transactionManager,
}
)
}
@@ -397,7 +397,7 @@ class HelloModuleService {
// ...
},
{
transaction: sharedContext.transactionManager
transaction: sharedContext.transactionManager,
}
)
}
@@ -430,7 +430,7 @@ class HelloModuleService {
// ...
},
{
isolationLevel: IsolationLevel.READ_COMMITTED
isolationLevel: IsolationLevel.READ_COMMITTED,
}
)
}
@@ -456,7 +456,7 @@ class HelloModuleService {
// ...
},
{
enableNestedTransactions: false
enableNestedTransactions: false,
}
)
}