                             ]
         if not @_validate_opts(opts) then return
         @_account(opts).pluck(opts.columns...).run (err, x) =>
+            console.log(err, x)
             if err
                 opts.cb(err)
             else if x.length == 0

            database : 'smc'
            password : undefined
            debug    : true
            cb       : undefined
        @_debug = opts.debug
        @_database = opts.database
        @_hosts = opts.hosts
        dbg = @dbg('constructor')
        password_file = rethinkdb_password_filename()
        async.series([
            (cb) =>
                if opts.password?
                    cb()
                else
                    fs.exists password_file, (exists) =>
                        if exists
                            fs.readFile password_file, (err, data) =>

                                    cb(err)
                                else
                                    dbg("read password from '#{password_file}'")
                                    @_password = data.toString().trim()
                                    cb()
                        else
                            cb()
            (cb) =>
                switch opts.driver
                    when 'dash'
                        dbg("initializing dash driver")
                        @_init_dash(cb)
                    when 'native'
                        dbg("initializing native driver")
                        @_init_native(cb)
                    else
                        cb?("unknown driver '#{opts.driver}'")
        ], (err) =>
            if err
                winston.debug("error initializing database -- #{misc.to_json(err)}")
            else
                @db = @r.db(@_database)
            opts.cb?(err, @)
        )

    _init_dash: (cb) =>
        #discovery   : true  # this option conflicts with password auth -- https://github.com/neumino/rethinkdbdash/issues/133
        opts =
            maxExponent : 4    # 15 seconds?
            timeout     : 10
            buffer      : 100
            max         : 15000  # max = simultaneous queries -- the default of 1000 is *way* too low; 200 people logging in hits this and everythign hangs up.
            servers     : ({host:h, authKey:@_password} for h in @_hosts)
        @r = rethinkdbdash(opts)
        cb()

    _init_native: (cb) =>
        @r = require('rethinkdb')
        that = @
        @r.connect {authKey:@_password,  host:@_hosts[0]}, (err, conn) =>
            if err
                cb(err); return
            @_conn = conn
            # Monkey patch run to have the same semantics as in rethinkdbdash, so that I don't have to change
            # any of the code below.  See http://stackoverflow.com/questions/26287983/javascript-monkey-patch-the-rethinkdb-run
            TermBase = @r.expr(1).constructor.__super__.constructor.__super__
            if not TermBase.run_native?  # only do this once!
                TermBase.run_native = TermBase.run
                TermBase.run = (opts, cb) ->
                    if not cb?
                        cb = opts
                        opts = undefined
                    #winston.debug("run query")
                    f = (err, result) ->
                        if err
                            #winston.debug("got err=#{misc.to_json(err)}")
                            cb(err)
                        else
                            # TODO: what's needed here is actually *MUCH* more complicated than what is below; see the
                            # rethinkdbdash source code....
                            #winston.debug("query success")
                            if result?.toArray?
                                try
                                    result = result?.toArray()
                                catch e
                                    # do nothing
                            cb(undefined, result)
                    if opts?
                        @run_native(that._conn, opts, f)
                    else
                        @run_native(that._conn, f)
            cb()

    table: (name) => @db.table(name)

