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'
}
}