loading...

How to migrate documents from one collection to another?

mayankjoshi profile image mayank joshi ・1 min read

We have an event management system, where we show active events around a user. What I am trying is to move an event data from active events collection to expired events collection as soon as the event is expired.

What do you think is the best way to do this in NodeJS & ExpressJs?

Discussion

markdown guide
 

Is it really necessary to move the documents into another collection? Usually, you would just add the expiration time to your events when you create them and index that key. You can then query the collection with the $gte or $lte operator to receive all the active or expired events.

 

Yes, we do need the list of expired events too.