0

I have an Order record that looks like:

{   cust_id : 5     , ordered_pdts : [ 1,2,3 ] }

I have Vendors collection. Each vendor record has a list of products the vendor maintains:

{   vendor_id : 342     , pdts : [ 4, 5, 6, 1, 2, 7, 3 ] }

When an order is placed, I need to find the vendors who have ALL the products listed in the Order.

Can this be done with a query operation or Aggregation Framework?

1 Answer 1

3

You can try with this query :

db.Vendor.find({'pdts' : {$all : [1,2,3]}})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.