   # end can be null. If so, returns all documents from start onwards.
   # Each document returned is in the form {op:o, meta:m, v:version}.
   @getOps = (docName, start, end, callback) ->
-    checkIndex ->
+    checkIndex (err) ->
+      return callback? err if err
       if start == end
         callback null, []
         return

        
  # Permanently deletes a document. There is no undo.
  @delete = (docName, dbMeta, callback) ->
    checkIndex ->
      client.collection 'ops', (err, collection) ->
        collection.remove { docName: docName }


  hostname: '127.0.0.1'
  port: 27017
  mongoOptions: {auto_reconnect: true}


# Valid options as above.
module.exports = MongoDb = (options) ->
