0 votes
1 view
in SQL by (32.5k points)

I have a collected named foo hypothetically.

Each instance of foo has a field called last looked at which is a UNIX timestamp since epoch. I'd like to be able to go through the MongoDB client and set that timestamp for all existing documents (about 20,000 of them) to the current timestamp.

What's the best way of handling this?

1 Answer

0 votes
by (76.8k points)

To update every document on one field this code will be helpful for you:-


'type': "newuser" 

}, { 

$set: { 

email: "[email protected]", 

phoneNumber:"0123456789" } 

}, { 

multi: true 


function(err, result) {