Skip to main content

IReviewModuleService Reference

This section of the documentation provides a reference to the IReviewModuleService interface’s methods. This is the interface developers use to use the functionalities provided by the Review 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 Review Module.

Methods


createReviews

This section provides a reference to the createReviews method. This belongs to the Review Module.

createReviews(data, sharedContext?): Promise<ReviewDTO[]>

This method creates reviews.

Example

Creating product reviews:
const reviews = await reviewModuleService.createReviews([
  {
    order_id: "ord_123",
    reference: "product",
    reference_id: "prod_123",
    rating: 5,
    customer_note: "Excellent product!",
    customer_id: "cus_123",
  },
])
Creating seller reviews:
const reviews = await reviewModuleService.createReviews([
  {
    order_id: "ord_123",
    reference: "seller",
    reference_id: "sel_123",
    rating: 4,
    customer_note: "Good service",
    customer_id: "cus_123",
  },
])

Parameters

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

Returns

Promise
Promise<ReviewDTO[]>
The created reviews.

createReviews(data, sharedContext?): Promise<ReviewDTO>

This method creates a review.

Example

const review = await reviewModuleService.createReviews({
  order_id: "ord_123",
  reference: "product",
  reference_id: "prod_123",
  rating: 5,
  customer_note: "Excellent product!",
  customer_id: "cus_123",
})

Parameters

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

Returns

Promise
Promise<ReviewDTO>
The created review.

updateReviews

This section provides a reference to the updateReviews method. This belongs to the Review Module.

updateReviews(id, data, sharedContext?): Promise<ReviewDTO>

This method updates an existing review.

Example

Customer updating their review:
const review = await reviewModuleService.updateReviews("rev_123", {
  rating: 4,
  customer_note: "Updated my review",
})
Seller responding to a review:
const review = await reviewModuleService.updateReviews("rev_123", {
  seller_note: "Thank you for your feedback!",
})

Parameters

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

Returns

Promise
Promise<ReviewDTO>
The updated review.

deleteReviews

This section provides a reference to the deleteReviews method. This belongs to the Review Module.

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

This method deletes reviews by their IDs.

Example

await reviewModuleService.deleteReviews(["rev_123", "rev_321"])

Parameters

ids
string[]
required
The IDs of the reviews.
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 reviews are deleted successfully.

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

This method deletes a review by its ID.

Example

await reviewModuleService.deleteReviews("rev_123")

Parameters

id
string
required
The ID of the review.
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 review is deleted successfully.

retrieveReview

This section provides a reference to the retrieveReview method. This belongs to the Review Module. This method retrieves a review by its ID.

Example

const review = await reviewModuleService.retrieveReview("rev_123")

Parameters

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

Returns

Promise
Promise<ReviewDTO>
The retrieved review.

listReviews

This section provides a reference to the listReviews method. This belongs to the Review Module. This method retrieves a paginated list of reviews based on optional filters and configuration.

Example

To retrieve product reviews:
const reviews = await reviewModuleService.listReviews({
  reference: "product",
  reference_id: "prod_123",
})
To retrieve seller reviews:
const reviews = await reviewModuleService.listReviews({
  reference: "seller",
  reference_id: "sel_123",
})
To retrieve a customer’s reviews:
const reviews = await reviewModuleService.listReviews({
  customer_id: "cus_123",
})
By default, only the first 15 records are retrieved. You can control pagination:
const reviews = await reviewModuleService.listReviews(
  {
    reference: "product",
    reference_id: "prod_123",
  },
  {
    take: 20,
    skip: 2,
  }
)

Parameters

filters
FilterableReviewProps
The filters to apply on the retrieved reviews.
config
FindConfig<ReviewDTO>
The configurations determining how the review is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<ReviewDTO[]>
The list of reviews.

listAndCountReviews

This section provides a reference to the listAndCountReviews method. This belongs to the Review Module. This method retrieves a paginated list of reviews along with the total count of available reviews satisfying the provided filters.

Example

To retrieve product reviews with count:
const [reviews, count] = await reviewModuleService.listAndCountReviews({
  reference: "product",
  reference_id: "prod_123",
})
To retrieve 5-star reviews:
const [reviews, count] = await reviewModuleService.listAndCountReviews({
  rating: 5,
})
By default, only the first 15 records are retrieved. You can control pagination:
const [reviews, count] = await reviewModuleService.listAndCountReviews(
  {
    customer_id: "cus_123",
  },
  {
    take: 20,
    skip: 2,
  }
)

Parameters

filters
FilterableReviewProps
The filters to apply on the retrieved reviews.
config
FindConfig<ReviewDTO>
The configurations determining how the review is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<[ReviewDTO[], number]>
The list of reviews along with their total count.

softDeleteReviews

This section provides a reference to the softDeleteReviews method. This belongs to the Review Module. This method soft deletes reviews by their IDs.

Example

await reviewModuleService.softDeleteReviews([
  "rev_123",
  "rev_321",
])

Parameters

reviewIds
string[]
required
The IDs of the reviews.
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.

restoreReviews

This section provides a reference to the restoreReviews method. This belongs to the Review Module. This method restores soft deleted reviews by their IDs.

Example

await reviewModuleService.restoreReviews(["rev_123", "rev_321"])

Parameters

reviewIds
string[]
required
The IDs of the reviews.
config
RestoreReturn<TReturnableLinkableKeys>
Configurations determining which relations to restore along with each of the review.
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.