0

I have a number of aggregations defined in my mongodb instance and I would like to delete one of them.

So for example if I had 3 defined in the collections _properties metadata and I wanted to get rid of the second one how would I do it.

IanBram
  • 257
  • 1
  • 3
  • 10
  • Please provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example-aka-mcve-minimal-complete-and-ver) – Emmanuel-Lin Nov 30 '17 at 12:22
  • Not sure if this is what you want but... { "aggrs": [ { "stages": [], "type": "pipeline", "uri": "myFirstAgg" }, { "stages": [], "type": "pipeline", "uri": "mySecondAgg" }, { "stages": [], "type": "pipeline", "uri": "myThirdAgg" } ] } I want to remove the #mySecondAgg' section – IanBram Nov 30 '17 at 12:35

1 Answers1

0

to create an aggregation you define the aggrs array as a collection property.

PATCH /db/coll {"aggrs": [ {<aggr1>}, {<aggr2>}, {<aggr3>} ] }

to delete one you just need to update the aggrs property

PATCH /db/coll {"aggrs": [ {<aggr1>}, {<aggr3>} ] }

you can also use the $pull array update operator:

PATCH /db/coll {"$pull": { "aggrs": { "uri": "mySecondAgg" } } }

Andrea Di Cesare
  • 1,125
  • 6
  • 11
  • Thanks, Andrea - I had kind of already come to the same conclusion (although not quite an elegant as your solution) I guess I thought I was meant to use the delete method of the API. – IanBram Dec 04 '17 at 12:13