Skip to main content

ISecondaryCategoryModuleService Reference

This section of the documentation provides a reference to the ISecondaryCategoryModuleService interface’s methods. This is the interface developers use to use the functionalities provided by the Secondary Category Module.
You should only use the methods in this reference when implementing complex customizations. For common cases, check out available workflows instead.
The main service interface for the Secondary Category Module.

Methods


createSecondaryCategories

This section provides a reference to the createSecondaryCategories method. This belongs to the Secondary Category Module.

createSecondaryCategories(data, sharedContext?): Promise<SecondaryCategoryDTO[]>

This method creates secondary categories.

Example

const secondaryCategories = await secondaryCategoryModuleService.createSecondaryCategories([
  {
    category_id: "pcat_123",
  },
  {
    category_id: "pcat_456",
  },
])

Parameters

data
CreateSecondaryCategoryDTO[]
required
The secondary categories to be created.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<SecondaryCategoryDTO[]>
The created secondary categories.

createSecondaryCategories(data, sharedContext?): Promise<SecondaryCategoryDTO>

This method creates a secondary category.

Example

const secondaryCategory = await secondaryCategoryModuleService.createSecondaryCategories({
  category_id: "pcat_123",
})

Parameters

data
CreateSecondaryCategoryDTO
required
The secondary category to be created.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<SecondaryCategoryDTO>
The created secondary category.

updateSecondaryCategories

This section provides a reference to the updateSecondaryCategories method. This belongs to the Secondary Category Module.

updateSecondaryCategories(id, data, sharedContext?): Promise<SecondaryCategoryDTO>

This method updates an existing secondary category.

Example

const secondaryCategory = await secondaryCategoryModuleService.updateSecondaryCategories("sec_cat_123", {
  category_id: "pcat_789",
})

Parameters

id
string
required
The ID of the secondary category.
data
UpdateSecondaryCategoryDTO
required
The attributes to update in the secondary category.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<SecondaryCategoryDTO>
The updated secondary category.

deleteSecondaryCategories

This section provides a reference to the deleteSecondaryCategories method. This belongs to the Secondary Category Module.

deleteSecondaryCategories(ids, sharedContext?): Promise<void>

This method deletes secondary categories by their IDs.

Example

await secondaryCategoryModuleService.deleteSecondaryCategories(["sec_cat_123", "sec_cat_321"])

Parameters

ids
string[]
required
The IDs of the secondary categories.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void>
Resolves when the secondary categories are deleted successfully.

deleteSecondaryCategories(id, sharedContext?): Promise<void>

This method deletes a secondary category by its ID.

Example

await secondaryCategoryModuleService.deleteSecondaryCategories("sec_cat_123")

Parameters

id
string
required
The ID of the secondary category.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void>
Resolves when the secondary category is deleted successfully.

retrieveSecondaryCategory

This section provides a reference to the retrieveSecondaryCategory method. This belongs to the Secondary Category Module. This method retrieves a secondary category by its ID.

Example

const secondaryCategory = await secondaryCategoryModuleService.retrieveSecondaryCategory("sec_cat_123")

Parameters

id
string
required
The ID of the secondary category.
config
FindConfig<SecondaryCategoryDTO>
The configurations determining how the secondary category is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<SecondaryCategoryDTO>
The retrieved secondary category.

listSecondaryCategories

This section provides a reference to the listSecondaryCategories method. This belongs to the Secondary Category Module. This method retrieves a paginated list of secondary categories based on optional filters and configuration.

Example

To retrieve a list of secondary categories using their IDs:
const secondaryCategories = await secondaryCategoryModuleService.listSecondaryCategories({
  id: ["sec_cat_123", "sec_cat_321"],
})
To retrieve secondary categories for a specific product category:
const secondaryCategories = await secondaryCategoryModuleService.listSecondaryCategories({
  category_id: "pcat_123",
})
By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:
const secondaryCategories = await secondaryCategoryModuleService.listSecondaryCategories(
  {
    category_id: "pcat_123",
  },
  {
    take: 20,
    skip: 2,
  }
)

Parameters

filters
FilterableSecondaryCategoryProps
The filters to apply on the retrieved secondary categories.
config
FindConfig<SecondaryCategoryDTO>
The configurations determining how the secondary category is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<SecondaryCategoryDTO[]>
The list of secondary categories.

listAndCountSecondaryCategories

This section provides a reference to the listAndCountSecondaryCategories method. This belongs to the Secondary Category Module. This method retrieves a paginated list of secondary categories along with the total count of available secondary categories satisfying the provided filters.

Example

To retrieve a list of secondary categories using their IDs:
const [secondaryCategories, count] = await secondaryCategoryModuleService.listAndCountSecondaryCategories({
  id: ["sec_cat_123", "sec_cat_321"],
})
By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:
const [secondaryCategories, count] = await secondaryCategoryModuleService.listAndCountSecondaryCategories(
  {
    category_id: "pcat_123",
  },
  {
    take: 20,
    skip: 2,
  }
)

Parameters

filters
FilterableSecondaryCategoryProps
The filters to apply on the retrieved secondary categories.
config
FindConfig<SecondaryCategoryDTO>
The configurations determining how the secondary category is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<[SecondaryCategoryDTO[], number]>
The list of secondary categories along with their total count.

softDeleteSecondaryCategories

This section provides a reference to the softDeleteSecondaryCategories method. This belongs to the Secondary Category Module. This method soft deletes secondary categories by their IDs.

Example

await secondaryCategoryModuleService.softDeleteSecondaryCategories([
  "sec_cat_123",
  "sec_cat_321",
])

Parameters

secondaryCategoryIds
string[]
required
The IDs of the secondary categories.
config
SoftDeleteReturn<TReturnableLinkableKeys>
An object that is used to specify an entity’s related entities that should be soft-deleted when the main entity is soft-deleted.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void | Record<string, string[]>>
An object that includes the IDs of related records that were also soft deleted. If there are no related records, the promise resolves to void.

restoreSecondaryCategories

This section provides a reference to the restoreSecondaryCategories method. This belongs to the Secondary Category Module. This method restores soft deleted secondary categories by their IDs.

Example

await secondaryCategoryModuleService.restoreSecondaryCategories(["sec_cat_123", "sec_cat_321"])

Parameters

secondaryCategoryIds
string[]
required
The IDs of the secondary categories.
config
RestoreReturn<TReturnableLinkableKeys>
Configurations determining which relations to restore along with each of the secondary category.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void | Record<string, string[]>>
An object that includes the IDs of related records that were restored. If there are no related records restored, the promise resolves to void.