K_H
K_H

Reputation: 29

How to remove documents from embedded where name is.. and start is greater than...?

I'm trying to remove some embedded documents from history. I'm using mongodb 3.2 There are two conditions:

  1. "name" must be for example sa
  2. "history" "start" must be greater some date
{
    "name" : "sa",
    "history" : [ 
        {
            "start" : ISODate("2015-11-11T12:46:32.000Z"),
            "value" : "color1"
        }, 
        {
            "start" : ISODate("2015-11-12T11:54:20.000Z"),
            "value" : "color2"
    }]
}
{
    "name" : "sa",
    "history" : [ 
        {
            "start" : ISODate("2015-11-11T12:46:32.000Z"),
            "value" : "color1"
        }, 
        ]
            "start" : ISODate("2015-11-12T11:54:20.000Z"),
            "value" : "color2"
    }] 
}
{
    "name" : "so",
    "history" : [ 
        {
            "start" : ISODate("2015-11-11T12:46:32.000Z"),
            "value" : "color1"
        }, 
        {
            "start" : ISODate("2015-11-12T11:54:20.000Z"),
            "value" : "color2"
    }] 
}

Upvotes: 0

Views: 31

Answers (1)

K_H
K_H

Reputation: 29

I couldn't do it directly. I download the collection and then do the operations that I need, remove the old collection and then insert the new collection with the data that I need.

Upvotes: 0

Related Questions