{ "_comment": [ "Inputs only. Expectations are measured -- see record.js.", "`$currentDate`, the one update operator whose result cannot be recorded", "as a value: it is whatever the clock said. `volatile` names the fields", "whose recorded value is replaced by a `$$type` assertion, so the case", "still pins the type, the position and every other field of the document", "-- everything except the number nobody can predict." ], "documents": [{ "_id": 1, "a": 1 }], "cases": [ { "description": "$currentDate with true writes a date", "volatile": ["d"], "operation": "updateOne", "arguments": { "filter": {}, "update": { "$currentDate": { "d": true } } } }, { "description": "$currentDate with an explicit date type", "volatile": ["d"], "operation": "updateOne", "arguments": { "filter": {}, "update": { "$currentDate": { "d": { "$type": "date" } } } } }, { "description": "$currentDate with the timestamp type", "volatile": ["d"], "operation": "updateOne", "arguments": { "filter": {}, "update": { "$currentDate": { "d": { "$type": "timestamp" } } } } }, { "description": "$currentDate overwrites a field that is already there", "volatile": ["a"], "operation": "updateOne", "arguments": { "filter": {}, "update": { "$currentDate": { "a": true } } } }, { "description": "$currentDate down a dotted path", "volatile": ["n.d"], "operation": "updateOne", "arguments": { "filter": {}, "update": { "$currentDate": { "n.d": true } } } }, { "description": "$currentDate beside another operator", "volatile": ["d"], "operation": "updateOne", "arguments": { "filter": {}, "update": { "$currentDate": { "d": true }, "$inc": { "a": 1 } } } }, { "description": "$currentDate with false, which is still a date", "volatile": ["d"], "operation": "updateOne", "arguments": { "filter": {}, "update": { "$currentDate": { "d": false } } } }, { "description": "$currentDate with an unknown type name", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$currentDate": { "d": { "$type": "nope" } } } } }, { "description": "$currentDate with a document that is not $type", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$currentDate": { "d": { "a": 1 } } } } }, { "description": "$currentDate with a number", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$currentDate": { "d": 1 } } } }, { "description": "$currentDate on an upsert that inserts", "documents": [], "volatile": ["d"], "operation": "updateOne", "arguments": { "filter": { "k": 1 }, "update": { "$currentDate": { "d": true } }, "upsert": true } } ] }