Get Started Free

9. Do supplier ratings hold up? Solved

CoreMedium$lookup$groupcomparing sources

Suppliers carry a rating we were given at onboarding. Compare it with what customers actually say: for each supplier with at least 8 reviews on its products, return supplier, reviews, avgReview (2 decimals), listedRating and gap = avgReview − listedRating (2 decimals). Sort by gap ascending (most overrated first).

Your answer returns 5 documents with the fields avgReview, gap, listedRating, reviews, supplier. Order matters.

The data

The shop database from the MongoDB playground, running in your browser. "Today" is 2026-11-18.

categories18 docs
_idObjectId
namestring
parentIdnull | ObjectId
pathstring
suppliers6 docs
_idObjectId
namestring
countrystring
ratingdouble
sincedate
products26 docs
_idObjectId
skustring
namestring
categoryIdObjectId
supplierIdObjectId
pricedecimal
tagsarray of string
stockarray of objects
warehouse qty
activeboolean
createdAtdate
customers30 docs
_idObjectId
namestring
emailstring
tierstring
addressesarray of objects
type street city country zip location
preferencesobject
newsletter currency
lifetimeValuedecimal
joinedAtdate
marketingOptInboolean
phonestring, 24 of 30
lastLogindate, 15 of 30
externalRefint | string, 10 of 30
loyaltyPointsint, 18 of 30
referredByObjectId, 17 of 30
orders220 docs
_idObjectId
numberstring
customerIdObjectId
placedAtdate
statusstring
statusHistoryarray of objects
status at
itemsarray of objects
productId sku name qty unitPrice
shippingobject
type street city country zip location method
totaldecimal
currencystring
supportAgentIdObjectId, 33 of 220
notestring, 33 of 220
reviews87 docs
_idObjectId
productIdObjectId
customerIdObjectId
orderIdObjectId
ratingint
commentstring
atdate
employees9 docs
_idObjectId
namestring
titlestring
reportsTonull | ObjectId

Hints

Common traps
  • Rounding avgReview first and then subtracting gives a slightly different gap: subtract, then round.

Solution

Run in the shell with Ctrl/⌘ + Enter. Check with Shift + Ctrl/⌘ + Enter.

"Check answer" runs your shell code on a fresh copy of the data, then on 2 hidden test datasets with more customers and orders, and compares each result with the expected one. The value of your last line is your answer.

Starting…