ReviewModuleService, reads and writes Review records directly and computes average ratings. Use it in subscribers, scheduled jobs, and routes when you don’t need a workflow’s validation, links, or compensation.
Resolve the service
Resolve the service from the Medusa container withMercurModules.REVIEW, which is the string "review":
query.graph from the linked side, as shown in the Links reference.
Generated methods
MedusaService generates these methods for the Review model:
Each write emits a mutation event, listed in the Events reference.
getAvgRating
Returns the average rating of one product or one seller.AVG of rating as a numeric string, such as "4.5000000000000000", or null when the target has no linked reviews. It counts every linked review whatever its status, including soft deleted ones.
getProductsWithRating
Returns every product with its average rating.fields are column names of the product table, such as ["id", "title"]. Each row gains a rating numeric string, or null. The query left joins the product_product_review_review link table and groups by product, with no filters, pagination, or deleted_at checks.
getSellersWithRating
Returns every seller with its average rating.fields are column names of the seller table, such as ["id", "name"]. It works like getProductsWithRating, joining through seller_seller_review_review.
The return types above describe the rows. The source declares no explicit return type for the two list helpers, so TypeScript infers Knex’s result type.