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. The ID of the order this review is associated with.
reference
"product" | "seller"
required
The type of entity being reviewed.
The ID of the entity being reviewed (product ID or seller ID).
The customer’s written review comment.
The ID of the customer who created the review.
A context used to share resources, such as transaction manager, between the application and the module.
Returns
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
The review to be created. The ID of the order this review is associated with.
reference
"product" | "seller"
required
The type of entity being reviewed.
The ID of the entity being reviewed (product ID or seller ID).
The customer’s written review comment.
The ID of the customer who created the review.
A context used to share resources, such as transaction manager, between the application and the module.
Returns
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
The attributes to update in the review. The customer’s written review comment.
The seller’s response to the review.
A context used to share resources, such as transaction manager, between the application and the module.
Returns
The updated review. The type of entity being reviewed.
The customer’s written review comment.
The ID of the customer who created the review.
The seller’s response to the review.
The created date of the review.
The updated date of the 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
A context used to share resources, such as transaction manager, between the application and the module.
Returns
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
A context used to share resources, such as transaction manager, between the application and the module.
Returns
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
The configurations determining how the review is retrieved. An array of strings, each being attribute names of the entity to retrieve in the result.
A number indicating the number of records to skip before retrieving the results.
A number indicating the number of records to return in the result.
An array of strings, each being relation names of the entity to retrieve in the result. Use Query to retrieve linked customer, product, or seller data.
order
Record<string, "ASC" | "DESC">
An object used to specify how to sort the returned records.
A boolean indicating whether deleted records should also be retrieved as part of the result.
A context used to share resources, such as transaction manager, between the application and the module.
Returns
The retrieved review. The type of entity being reviewed.
The customer’s written review comment.
The ID of the customer who created the review.
The seller’s response to the review.
The created date of the review.
The updated date of the 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
The filters to apply on the retrieved reviews. The IDs to filter the reviews by.
Filter reviews by their reference type (product or seller).
Filter reviews by the ID of the entity being reviewed.
Filter reviews by their customer IDs.
Filter reviews by their rating values.
The configurations determining how the review is retrieved. An array of strings, each being attribute names of the entity to retrieve in the result.
A number indicating the number of records to skip before retrieving the results.
A number indicating the number of records to return in the result.
An array of strings, each being relation names of the entity to retrieve in the result.
order
Record<string, "ASC" | "DESC">
An object used to specify how to sort the returned records.
A boolean indicating whether deleted records should also be retrieved as part of the result.
A context used to share resources, such as transaction manager, between the application and the module.
Returns
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
The filters to apply on the retrieved reviews. The IDs to filter the reviews by.
Filter reviews by their reference type (product or seller).
Filter reviews by the ID of the entity being reviewed.
Filter reviews by their customer IDs.
Filter reviews by their rating values.
The configurations determining how the review is retrieved. An array of strings, each being attribute names of the entity to retrieve in the result.
A number indicating the number of records to skip before retrieving the results.
A number indicating the number of records to return in the result.
An array of strings, each being relation names of the entity to retrieve in the result.
order
Record<string, "ASC" | "DESC">
An object used to specify how to sort the returned records.
A boolean indicating whether deleted records should also be retrieved as part of the result.
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
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.
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
config
RestoreReturn<TReturnableLinkableKeys>
Configurations determining which relations to restore along with each of the review.
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.