[SERVER-2064] $sysdate for inserts/updates Created: 05/Nov/10  Updated: 17/Jan/18  Resolved: 26/Feb/16

Status: Closed
Project: Core Server
Component/s: Usability
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor - P4
Reporter: Christoph Preissner Assignee: Unassigned
Resolution: Duplicate Votes: 4
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

all


Issue Links:
Duplicate
duplicates SERVER-10911 Add $currentDate update modifier Closed
Related
is related to SERVER-13695 Support $currentDate expression for i... Backlog
Participants:

 Description   

I would like to ask for the following feature:

on inserts/updates I would like to have a "placeholder" like "$sysdate" as argument, telling the database engine to replace the "$sysdate-placeholder" by the current database UTC before putting it in the internal mongodb queue.

e.g.: db.coll.insert(

{"tx":"test string","timestamp":$sysdate}

)

The advantage would be that one can be sure that sorting by the timestamp of the document field results in the 100% sortorder of insertion; if I insert data from different machines, I have no guarantee about the insertion sortorder in the internal queue of MongoDB for persisting ( depending on the application delay for "getting the data and pushing it to mongodb" ).

Thank you for taking this into consideration,ยด



 Comments   
Comment by David Storch [ 26/Feb/16 ]

Closing as a duplicate of SERVER-13695.

Comment by Aleksandar Kostadinov [ 28/Oct/14 ]

It would be very useful if arithmetic operations are possible with current date. For example if resource reservation is implemented and one is doing findAndModify atomic operation on that resource, it would be very useful to be able to set document's `reserved_until` field to `$now+##units`.
The thing is that sometimes clients can't be controlled and kept in time sync with each other. To avoid any troubles server time should be used.

Comment by Abhishek Guha Thakurta [ 03/Sep/14 ]

Hello Fred,
A question regarding the dates on the same lines. We intend to pass a JSON expression of the current date to our date-field. Could you help us out with the right way to do this (We do not intend to use new Date() field)

{ $match :

{ <our date field> : "$date:now" }}
Comment by Fred Stluka [ 07/Apr/11 ]

This would be a very useful feature.

Exactly like the sysdate feature of MySQL, Oracle, and others.

Here's what we're doing now:

We don't want dates captured in the Web client. So instead of passing
'$date:' followed by a client-side millisecond counter, as part of our JSON
string to the Web server, we pass '$date:now' to the Web server, and our
code in the Web server replaces 'now' with a server-side millisecond
counter before passing the JSON string to Mongo. That means all dates
are captured on the Web server, not in the various Web browsers.

So far, so good, but we still need a way for the various Web servers to
pass the responsibility on to the Mongo DB server. It would be great if
Mongo would support a $sysdate that would cause it to capture and
store the current time on the Mongo DB server.

Generated at Thu Feb 08 02:58:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.