             TermBase.run = ->
                 throw new Error("You should remove .run() from your queries when using the Data Explorer.\nThe query will be built and sent by the Data Explorer itself.")
 
+    # Open a connection to the server
     connect: (callback) ->
         r.connect @server, callback
 
+    # Run a query once
     run_once: (query, callback) =>
         @connect (error, connection) =>
             if error?

window.system_db = 'rethinkdb'

$ ->
    window.r = require('rethinkdb')
    window.driver = new Driver

    main_view = new MainView.MainContainer()
    $('body').html main_view.render().$el

    main_view.start_router()

    Backbone.sync = (method, model, success, error) ->

                            callback(err, result)


    # Run the query every `delay` ms
    # Returns a timeout number (to use with @stop_timer).
    # If `index` is provided, `run` will its value as a timer
    run: (query, delay, callback, index) =>
        if not index?
            @index++
        index = @index
        @timers[index] = {}
        ( (index) =>
            @connect (error, connection) =>
                if error?
