Hello guys.I want to delete some of my documents.My collections look like this:
{
"_id" : ObjectId("608d84777791538ce2a09f2f"),
"nsamples" : 288,
"samples" : [
{
"20" : ISODate("1980-01-01T00:00:00Z"),
"1" : 3758,
"2" : 2,
"3" : -79.09,
"4" : 35.97,
"5" : 5.5,
"6" : 0,
"7" : -99999,
"8" : 0,
"9" : -9999,
"10" : "U",
"11" : 0,
"12" : 99,
"13" : 0,
"14" : -99,
"15" : -9999,
"16" : 33,
"17" : 0,
"18" : -99,
"19" : 0,
"21" : "2009-12-31 19:05:00"
},
{
"20" : ISODate("1980-01-01T00:05:00Z"),
"1" : 3758,
"2" : 2,
"3" : -79.09,
"4" : 35.97,
"5" : 5.5,
"6" : 0,
"7" : -99999,
"8" : 0,
"9" : -9999,
"10" : "U",
"11" : 0,
"12" : 99,
"13" : 0,
"14" : -99,
"15" : -9999,
"16" : 33,
"17" : 0,
"18" : -99,
"19" : 0,
"21" : "2009-12-31 19:05:00"
},
.
.
.
.
The query i am trying to execute is this:
mydb1.insertion_testbucket.delete_many({"samples.20": {"$lt": datetime.strptime("1980-01-01 02:00:00", "%Y-%m-%d %H:%M:%S")}})
I only want to delete some of the nested subdocuments in the first document,and not the whole first document.Is this the right way?
I want your advice before i execute it.Thanks in advance guys!