Skip to main content
The Review module service, 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 with MercurModules.REVIEW, which is the string "review":
This lists the 20 newest published reviews and the total count. Filters apply to the review’s own fields, so you can’t filter by product or seller here: use query.graph from the linked side, as shown in the Links reference.
Writing through the service skips the workflow checks. createReviews doesn’t validate the order, reject duplicates, or write any link, and updateReviews doesn’t stop a second store answer.

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.
The result is the Postgres 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.