chore: abstract the modules repository (#6035)
**What** Reduce the work effort to create repositories when building new modules by abstracting the most common cases into the base class default implementation returned by a factory - [x] Migrate all modules Co-authored-by: Riqwan Thamir <5105988+riqwan@users.noreply.github.com>
This commit is contained in:
co-authored by
Riqwan Thamir
parent
ef5024980d
commit
b6ac768698
@@ -5,6 +5,7 @@ import {
|
||||
MedusaContext,
|
||||
ModulesSdkUtils,
|
||||
retrieveEntity,
|
||||
validateRuleAttributes,
|
||||
} from "@medusajs/utils"
|
||||
import { RuleType } from "@models"
|
||||
import { ServiceTypes } from "@types"
|
||||
@@ -69,6 +70,7 @@ export default class RuleTypeService<TEntity extends RuleType = RuleType> {
|
||||
data: ServiceTypes.CreateRuleTypeDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
): Promise<TEntity[]> {
|
||||
validateRuleAttributes(data.map((d) => d.rule_attribute))
|
||||
return (await this.ruleTypeRepository_.create(
|
||||
data,
|
||||
sharedContext
|
||||
@@ -80,6 +82,7 @@ export default class RuleTypeService<TEntity extends RuleType = RuleType> {
|
||||
data: ServiceTypes.UpdateRuleTypeDTO[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
): Promise<TEntity[]> {
|
||||
validateRuleAttributes(data.map((d) => d.rule_attribute))
|
||||
return (await this.ruleTypeRepository_.update(
|
||||
data,
|
||||
sharedContext
|
||||
|
||||
Reference in New Issue
Block a user