mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 08:13:31 +02:00
Save devices to database.
This commit is contained in:
@@ -12,3 +12,32 @@ module.exports.saveUserAfterLogin = function(user) {
|
||||
upsert: true
|
||||
}))
|
||||
}
|
||||
|
||||
module.exports.saveDeviceStatus = function(serial, status) {
|
||||
return db.run(r.table('devices').get(serial).update({
|
||||
status: status
|
||||
, statusChangedAt: r.now()
|
||||
}))
|
||||
.then(function(stats) {
|
||||
if (stats.skipped) {
|
||||
return db.run(r.table('devices').insert({
|
||||
serial: serial
|
||||
, status: status
|
||||
, statusChangedAt: r.now()
|
||||
, createdAt: r.now()
|
||||
}))
|
||||
}
|
||||
return stats
|
||||
})
|
||||
}
|
||||
|
||||
module.exports.saveDeviceIdentity = function(serial, identity) {
|
||||
return db.run(r.table('devices').get(serial).update({
|
||||
platform: identity.platform
|
||||
, manufacturer: identity.manufacturer
|
||||
, model: identity.model
|
||||
, version: identity.version
|
||||
, abi: identity.abi
|
||||
, sdk: identity.sdk
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user