[SERVER-10911] Add $currentDate update modifier Created: 25/Sep/13  Updated: 02/Aug/18  Resolved: 28/Sep/13

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: None
Fix Version/s: 2.5.3

Type: Task Priority: Major - P3
Reporter: Scott Hernandez (Inactive) Assignee: Gregory McKeon (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on DRIVERS-121 support new update operators Closed
Duplicate
is duplicated by SERVER-1650 Server Side Timestamps Closed
is duplicated by SERVER-2064 $sysdate for inserts/updates Closed
is duplicated by SERVER-10123 Support Timestamp(0,0) server replace... Closed
Related
related to DOCS-2013 new update operator $currentDate Closed
Participants:

 Description   

Add a new update modifier where the server will fill in the date/timestamp:

Usage:

update({}, {$currentDate: { 
    field : true, //new Date()
    field1: {$type: "date"}, //new Date()
    field2: {$type: "timestamp"} //new Timestamp()
 }}



 Comments   
Comment by gross [ 13/Apr/16 ]

gianfranco@10gen.com, I looked through mongodb 2.6, 3.0 and 3.2 source code and found that new BSONTimestamp(0, 0) in document to insert works for all fields (not for 1st and 2nd as it was in older mongodb) and produces unique timestamp for each field.

Comment by gross [ 13/Apr/16 ]

ivan@kinvey.com, at least in mongo 2.6 and 3.2 this timestamp is unique for mongod instance. I'm not sure if it's unique in replSet but think it should be.

Comment by Gianfranco Palumbo [ 28/Mar/14 ]

Could this operator be implemented for inserts?
It would be useful with a TTL index since it doesn't don't support _id

Comment by Ivan Stoyanov [ 05/Feb/14 ]

Hi, how atomic or close to atomic is that operation?

Comment by auto [ 01/Oct/13 ]

Author:

{u'username': u'scotthernandez', u'name': u'Scott Hernandez', u'email': u'scotthernandez@gmail.com'}

Message: SERVER-1534 SERVER-10911: enable curentDate/min/max mods
Branch: master
https://github.com/mongodb/mongo/commit/278f1b43f51a62989ac91741b20fbf3adb6733b2

Comment by auto [ 27/Sep/13 ]

Author:

{u'username': u'scotthernandez', u'name': u'Scott Hernandez', u'email': u'scotthernandez@gmail.com'}

Message: SERVER-10911: Add $currentDate update modifier
Branch: master
https://github.com/mongodb/mongo/commit/02d5e9521f71e1a090da489a594087352a00016c

Generated at Thu Feb 08 03:24:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.