Additional aggregation stages

Scott Colestock shared this question 7 years ago

I'm doing an aggregate (with a qb.where(...).where(...)) followed by a .project(...)

After that...I'd like to do more matching. It seems like I have to fall back on the standard match method with a json object at that point.

Is there a way to use the fluent api with aggregation where you can continue to use the where clause after projecting, etc. ?

Replies (1)


Like this?

  1. db.testCols.aggregate()
  2. .match(
  3. qb.where("status").eq("A")
  4. .where(qb.where("f1").eq("something").build()) //nested qb build
  5. )
  6. .project("gender _id f2")
  7. .match(qb.where("f2").eq("something"))
  8. .getShellScript() //use getShellScript to return MongoShell script


Thank you - missed that match would take a query builder. My mistake. Might want to add "match" function to the list here:

Leave a Comment
Attach a file