summaryrefslogtreecommitdiff
path: root/jstests/update_currentdate_examples.js
blob: 055bd3089daf4876cb009e91684d8ceef4a57a07 (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
// Basic examples for $currentDate
var coll = db.update_currentdate;
coll.drop();

// $currentDate default
coll.remove({})
coll.save({_id:1, a:2});
coll.update({}, {$currentDate: {a: true}})
assert.gleSuccess(coll.getDB())
assert(coll.findOne().a.constructor == Date)

// $currentDate type = date
coll.remove({})
coll.save({_id:1, a:2});
coll.update({}, {$currentDate: {a: {$type: "date"}}})
assert.gleSuccess(coll.getDB())
assert(coll.findOne().a.constructor == Date)

// $currentDate type = timestamp
coll.remove({})
coll.save({_id:1, a:2});
coll.update({}, {$currentDate: {a: {$type: "timestamp"}}})
assert.gleSuccess(coll.getDB())
assert(coll.findOne().a.constructor == Timestamp)