Pop last version, not last timestamp

This commit is contained in:
James Allen 2014-03-07 14:02:16 +00:00
parent b45db3aa2b
commit 866084ee6b
2 changed files with 3 additions and 3 deletions

View file

@ -5,7 +5,7 @@ module.exports = MongoManager =
getLastCompressedUpdate: (doc_id, callback = (error, update) ->) ->
db.docHistory
.find(doc_id: ObjectId(doc_id.toString()))
.sort( "meta.end_ts": -1)
.sort( v: -1 )
.limit(1)
.toArray (error, compressedUpdates) ->
return callback(error) if error?

View file

@ -34,9 +34,9 @@ describe "MongoManager", ->
.calledWith(1)
.should.equal true
it "should sort in descending timestamp order", ->
it "should sort in descending version order", ->
@db.docHistory.sort
.calledWith("meta.end_ts": -1)
.calledWith(v: -1)
.should.equal true
it "should call the call back with the update", ->