STF的數據庫使用的是RethinkDB。RethinkDB啓動後,在瀏覽器裏輸入http://stf_server_ip:8080即可打開RethinkDB後臺管理中心。
在STF中,定義數據庫的文件爲stf_home/lib/db/tables.js。
var r = require('rethinkdb')
module.exports = {
users: {//user表
primaryKey: 'email'
, indexes: {
adbKeys: {
indexFunction: function(user) {
return user('adbKeys')('fingerprint')
}
, options: {
multi: true
}
}
}
}
, accessTokens: {//accessTokens表
primaryKey: 'id'
, indexes: {
email: null
}
}
, vncauth: {//vncauth表
primaryKey: 'password'
, indexes: {
response: null
, responsePerDevice: {
indexFunction: function(row) {
return [row('response'), row('deviceId')]
}
}
}
}
, devices: {//devices表
primaryKey: 'serial'
, indexes: {
owner: {
indexFunction: function(device) {
return r.branch(
device('present')
, device('owner')('email')
, r.literal()
)
}
}
, present: null
, providerChannel: {
indexFunction: function(device) {
return device('provider')('channel')
}
}
}
}
, logs: {//logs表
primaryKey: 'id'
}
}