Skip to content

Commit

Permalink
Set createdAt only when a device is inserted for the first time.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorccu committed Dec 2, 2014
1 parent 34bf8ad commit ed106ab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/db/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ dbapi.saveDevice = function(serial, device) {
, status: device.status
, ready: false
, statusChangedAt: r.now()
, createdAt: r.now()
, lastHeartbeatAt: r.now()
, reverseForwards: []
}
return db.run(r.table('devices').get(serial).update(data))
.then(function(stats) {
if (stats.skipped) {
data.serial = serial
data.createdAt = r.now()
return db.run(r.table('devices').insert(data))
}
return stats
Expand Down

0 comments on commit ed106ab

Please sign in to comment.