ravi45722 has asked for the wisdom of the Perl Monks concerning the following question:
In my DB so much old data is there. I want to remove which is older than 3 months(90 days). For that I came upto here.
#!/usr/bin/perl use strict; use warnings; use MongoDB; $db_host="xxx.xx.xx.xxx"; #Removed ip for security purposes my $client = MongoDB::MongoClient->new(host => $db_host, port => 2 +7017); my $database = $client->get_database( 'ravi' ); my $collection1 = $database->get_collection( 'collection' ); my $removed1 = $collection1->remove({'Date'=>{'$lt'=>"14-03-2015"}}); print "\n$removed1";
here my problem is in my command if I write 14-03-2015 Its deleting second month & third month of year 2015 & 2104. But not 12 to 4 months of 2014 data. Suppose if i give 14-12-2014 like this it will remove total data of that collection. Means its considering only month but not year. Please show me a proper approach
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Remove DB old data in Mongo using Perl
by Corion (Patriarch) on Sep 16, 2015 at 07:09 UTC |