I have a collected named foo hypothetically.
Each instance of foo has a field called lastLookedAt which is a UNIX timestamp since epoch. I\
Regardless of the version, for your example, the is:
{ $set: { lastLookedAt: Date.now() / 1000 } }
However, depending on your version of MongoDB, the query will look different. Regardless of version, the key is that the empty condition {} will match any document. In the Mongo shell, or with any MongoDB client:
$version >= 3.2:
db.foo.updateMany( {}, )
{} is the condition (the empty condition matches any document)3.2 > $version >= 2.2:
db.foo.update( {}, , { multi: true } )
{} is the condition (the empty condition matches any document){multi: true} is the "update multiple documents" option$version < 2.2:
db.foo.update( {}, , false, true )
{} is the condition (the empty condition matches any document)false is for the "upsert" parametertrue is for the "multi" parameter (update multiple records)