From 443237393f34532c205cfd4e0d566c90ff4436d7 Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Mon, 13 Apr 2015 13:46:21 -0400 Subject: Fix autoincrement bug max index wasn't being resolved correctly --- app/node_modules/okdb/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/node_modules/okdb/index.js') diff --git a/app/node_modules/okdb/index.js b/app/node_modules/okdb/index.js index 85156d1..5aa22a2 100644 --- a/app/node_modules/okdb/index.js +++ b/app/node_modules/okdb/index.js @@ -180,7 +180,7 @@ FSDB.prototype.getMeta = function() { */ function autoincrement(wrapper, schema, data) { return schema.autoIncrementFields.reduce(function(data, field) { - var last = wrapper.chain().sort(field).first().value(); + var last = wrapper.chain().sortByOrder([field], [true]).last().value(); var index = last ? last[field] : -1; var incremented = {}; incremented[field] = (parseInt(index) + 1); -- cgit v1.2.3-70-g09d2