Help i overwrote a ton of data

I have a database called tutorials with a field called url which i accidentally overwrote for all 500 entries.

I have an older backup luckily, but I cant figure out how to use that to fix my situation. I cannot just drop the new db and import the old one because there are other fields that have been updated since.

I just want to import the url field from the old one.

I am using a hosted mongodb server and connecting / managing it with compass.

I exported the tutorials data from my old backup, with just the ID field and the URL field.

I tried to import this old data with the “add data” button, but it throws an error saying the ID is a duplicate. But i dont want to insert these documents, i want to use them to update. I don’t see an option for this.

I see people saying to use mongoimport, but that doesn’t seem to exist within the “mongosh” command line at the bottom of compass.

How do?

You are in the right direction.

The command mongoimport is not part of mongosh, you start it from the windows cmd or PowerShell terminal.

With Compass, use Add Data but into a temporary collection.

Then use the aggregation framework to $merge the temporary collection into the original collection.

i dont seem to have it installed, was hoping to not have to install additional software, or have to figure out how to log in via command line (since it’s already working in compass).

is there really no way to do it from within compass?

Like I wrote

You can use

within Compass, or Compass’ integrated mongosh

2 Likes