summaryrefslogtreecommitdiff
path: root/app/node_modules/okdb/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/node_modules/okdb/index.js')
-rw-r--r--app/node_modules/okdb/index.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/app/node_modules/okdb/index.js b/app/node_modules/okdb/index.js
index c9dca99..7639ec6 100644
--- a/app/node_modules/okdb/index.js
+++ b/app/node_modules/okdb/index.js
@@ -1,8 +1,10 @@
-var Q = require('q');
+var assign = require('object-assign')
var cloneDeep = require('lodash.clonedeep');
var isobject = require('lodash.isobject');
var format = require('util').format;
var low = require('lowdb');
+var Q = require('q');
+
low.mixin(low.mixin(require('underscore-db')));
/**
@@ -146,10 +148,10 @@ FSDB.prototype.getMeta = function() {
*/
function autoincrement(wrapper, schema, data) {
return schema.autoIncrementFields.reduce(function(data, field) {
- var last = wrapper.chain().sort(field).last().value();
+ var last = wrapper.chain().sort(field).first().value();
var index = last ? last[field] : -1;
var incremented = {};
- incremented[field] = index + 1;
+ incremented[field] = (parseInt(index) + 1) % Number.MAX_SAFE_INT;
return assign(data, incremented);
}, data);
}