       callback null, []
       return
 
-    client.collection 'ops', (err, collection) ->
+    client.collection opsCollectionForDoc(docName), (err, collection) ->
       return callback? err if err
       
       query = 
-        docName: docName
-        v:
+        _id:
           $gte: start
-      query.v.$lt = end if end
+      query._id.$lt = end if end
       
-      collection.find(query).sort('v').toArray (err, docs) ->
+      collection.find(query).sort('_id').toArray (err, docs) ->
         console.warn "failed to get ops for #{docName}: #{err}" if err
         return callback? err if err
 


  client = new mongodb.Db(options.db, new mongodb.Server(options.hostname, options.port, options.mongoOptions))

  client.ensureIndex 'ops', {docName: 1, v: 1}, {unique: true}, (err, name) ->
    console.warn "failed to ensure mongo index on ops collection: #{err}\nperformance may suffer" if err

  # Creates a new document.
  # data = {snapshot, type:typename, [meta]}

        
  # Permanently deletes a document. There is no undo.
  @delete = (docName, dbMeta, callback) ->
    client.collection opsCollectionForDoc(docName), (err, collection) ->
      collection.drop()

    client.collection 'docs', (err, collection) ->
      return callback? err if err
