Help with aggregation query

Hi everyone
Can i get some help on the following?
This is my current code:
db.getCollection(“JS_products”).aggregate([

{$match:{JS_asin:“Product ID”}},

{$match:{JS_categories:“Shorts”}}])

However the question asks the following:
List the product ID and title of all products in the “Shorts” category. No other
product details are required. I need to use the aggregation pipeline method.
Can someone help out as to what to do? i should end up with 8 or more outputs.

It is unclear but you might want to look at https://docs.mongodb.com/manual/reference/operator/aggregation/project/

Hi Jeffery,

It sounds like this might be related to an assignment or tutorial.

To help with your learning, I suggest posting:

  • a sample document
  • what you’ve tried so far
  • any errors or problems encountered

If this is related to a MongoDB University course, please ask in the course forum. We generally want to avoid posting spoilers or solutions for homework.

Regards,
Stennie

1 Like