diff options
Diffstat (limited to 'app/node_modules')
| -rw-r--r-- | app/node_modules/okdb/index.js | 8 | ||||
| -rw-r--r-- | app/node_modules/okdb/package.json | 1 | ||||
| -rw-r--r-- | app/node_modules/okschema/index.js | 3 |
3 files changed, 8 insertions, 4 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); } diff --git a/app/node_modules/okdb/package.json b/app/node_modules/okdb/package.json index a6d13ff..5184cb6 100644 --- a/app/node_modules/okdb/package.json +++ b/app/node_modules/okdb/package.json @@ -12,6 +12,7 @@ "lodash.clonedeep": "^3.0.0", "lodash.isobject": "^3.0.1", "lowdb": "^0.7.2", + "object-assign": "^2.0.0", "q": "^1.2.0", "underscore-db": "^0.8.1" } diff --git a/app/node_modules/okschema/index.js b/app/node_modules/okschema/index.js index 1528eab..4633e7a 100644 --- a/app/node_modules/okschema/index.js +++ b/app/node_modules/okschema/index.js @@ -97,7 +97,8 @@ function OKSchema(spec) { // Register autoincrement fields // NOTE Does not work for nested fields var autoIncrementFields = specKeys.reduce(function(arr, prop) { - if (spec[prop] === 'autoincrement') { + var specProp = spec[prop]; + if (specProp.autoincrement) { arr.push(prop); } return arr; |
