I want to backup certain documents in a MongoDB collection. These documents change from day to day in a Node.js/Mongoose app, and I want to be able to restore these documents (and only these documents) to any former state. Are there any best practices to backup and restore single documents?
I already came up with a simple approach to store the documents in a backup collection on a daily basis:
let backupData = new BackupData({
title: document_title,
timestamp: new Date(),
data: document_data
})
backupData.save()
From this collection, I can load a previously stored document indicating its title and timestamp. Probably not the best solution. And I am also stuck at the point how to restore the document. Just saving it does not change the document in the database (no error thrown).