OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Mongodb deleteMany or dump with specified date

  • Thread starter Thread starter empoy
  • Start date Start date
E

empoy

Guest
Maybe this subject often question to ask, but I not find what I want it. I have a collection with keys and values like this:

Code:
{
  _id: ObjectId("6142f3a47245125aef7ffcc0"),
  addTime: '2021-09-16 14:35:00',
  editTime: '2021-09-16 14:35:00'
}

I want to dump before August 2021. What syntax do I have to use? I trying in roboT and mongo shell, before dump I try find first.

Code:
db.collections.find({addTime:{$lte:new Date("2021-09-01")}})

and the result is

Code:
Fetched 0 record(s) in 3714ms

<p>Maybe this subject often question to ask, but I not find what I want it.
I have a collection with keys and values like this:</p>
<pre class="lang-json prettyprint-override"><code>{
_id: ObjectId("6142f3a47245125aef7ffcc0"),
addTime: '2021-09-16 14:35:00',
editTime: '2021-09-16 14:35:00'
}
</code></pre>
<p>I want to dump before August 2021. What syntax do I have to use?
I trying in roboT and mongo shell, before dump I try find first.</p>
<pre><code>db.collections.find({addTime:{$lte:new Date("2021-09-01")}})
</code></pre>
<p>and the result is</p>
<pre><code>Fetched 0 record(s) in 3714ms
</code></pre>
 

Latest posts

Top