blob: 466ce96e5cca24d9eb29f7edf84be17f7d4951fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
// Basic examples for $currentDate
var res;
var coll = db.update_currentdate;
coll.drop();
// $currentDate default
coll.remove({});
coll.save({_id: 1, a: 2});
res = coll.update({}, {$currentDate: {a: true}});
assert.writeOK(res);
assert(coll.findOne().a.constructor == Date);
// $currentDate type = date
coll.remove({});
coll.save({_id: 1, a: 2});
res = coll.update({}, {$currentDate: {a: {$type: "date"}}});
assert.writeOK(res);
assert(coll.findOne().a.constructor == Date);
// $currentDate type = timestamp
coll.remove({});
coll.save({_id: 1, a: 2});
res = coll.update({}, {$currentDate: {a: {$type: "timestamp"}}});
assert.writeOK(res);
assert(coll.findOne().a.constructor == Timestamp);
|