                     cb(err)
                 else
                     cb(undefined, records.length==0)
-
-    create_account: (opts={}) ->
-        opts = defaults opts,
-            first_name        : required
-            last_name         : required
-
-            email_address     : undefined
-            password_hash     : undefined
-
-            passport_strategy : undefined
-            passport_id       : undefined
-            passport_profile  : undefined
-            cb                : required
 
     all_users: (cb) =>
         # TODO

class RethinkDB
    constructor : (opts={}) ->
        opts = defaults opts,
            hosts    : ['localhost']
            password : undefined   # TODO
        @r = require('rethinkdbdash')()
        @db = @r.db('smc')

    dbg: (f) ->
        return (m) -> winston.debug("RethinkDB.#{f}: #{m}")

    create_schema: (cb) =>
        dbg = @dbg("create_schema")
        async.series([
            (cb) =>
                dbg("create db")
                @r.dbCreate('smc').run(cb)
            (cb) =>
                dbg("create #{TABLES.length} tables")
                async.map(TABLES, ((table, cb) => @db.tableCreate(table).run(cb)), cb)
            (cb) =>
                dbg("create indexes") # TODO - use some kind of JSON object to describe...
                @db.table("central_log").indexCreate('time').run(cb)
                @db.table("central_log").indexCreate('event').run(cb)
        ], (err) => cb?(err))

    key_value_store: (opts={}) => # key_value_store(name:"the name")

{defaults} = misc = require('misc')
required = defaults.required

###
# Schema
#   keys are the table names
#   values describe the indexes
###
TABLES =
    accounts    : false
    central_log :
        time  : []
        event : []
    counts      : false
    key_value   : false

PROJECT_GROUPS = misc.PROJECT_GROUPS

