STF -- 数据库定义

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


发布了77 篇原创文章 · 获赞 30 · 访问量 27万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章