Skip to content

Commit

Permalink
Fix bug with upgrading version
Browse files Browse the repository at this point in the history
Changed to not attempt to add object store if it already exists
  • Loading branch information
erikolson186 committed Jun 21, 2017
1 parent c338839 commit f1cea70
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 49 deletions.
12 changes: 12 additions & 0 deletions build/src/cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ var Cursor = function (_EventEmitter) {
throw Error('cursor has already been opened');
}
}

/**
* Suggest an index to use.
* <strong>Note:</strong> When an index hint is used only documents
* that contain the indexed path will be in the results.
* @param {string} path An indexed path to use.
* @return {Cursor}
*
* @example
* col.find().hint('myindex');
*/

}, {
key: 'hint',
value: function hint(path) {
Expand Down
6 changes: 3 additions & 3 deletions build/src/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ var Db = function (_EventEmitter) {

for (var name in _this2._config) {
try {
if (_this2._config[name]) {
_this2._addStore(idb, name);
} else {
if (!_this2._config[name]) {
idb.deleteObjectStore(name);
} else if (!idb.objectStoreNames.contains(name)) {
_this2._addStore(idb, name);
}
} catch (error) {
return cb(error);
Expand Down
93 changes: 52 additions & 41 deletions dist/zangodb-test-suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,18 @@ var Cursor = function (_EventEmitter) {
throw Error('cursor has already been opened');
}
}

/**
* Suggest an index to use.
* <strong>Note:</strong> When an index hint is used only documents
* that contain the indexed path will be in the results.
* @param {string} path An indexed path to use.
* @return {Cursor}
*
* @example
* col.find().hint('myindex');
*/

}, {
key: 'hint',
value: function hint(path) {
Expand Down Expand Up @@ -1534,10 +1546,10 @@ var Db = function (_EventEmitter) {

for (var name in _this2._config) {
try {
if (_this2._config[name]) {
_this2._addStore(idb, name);
} else {
if (!_this2._config[name]) {
idb.deleteObjectStore(name);
} else if (!idb.objectStoreNames.contains(name)) {
_this2._addStore(idb, name);
}
} catch (error) {
return cb(error);
Expand Down Expand Up @@ -26130,68 +26142,67 @@ module.exports.typeDetect = module.exports;

}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],383:[function(require,module,exports){
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.deepmerge = factory();
}
}(this, function () {
'use strict';

function isMergeableObject(val) {
var nonNullObject = val && typeof val === 'object'
var index$2 = function isMergeableObject(value) {
return isNonNullObject(value) && isNotSpecial(value)
};

return nonNullObject
&& Object.prototype.toString.call(val) !== '[object RegExp]'
&& Object.prototype.toString.call(val) !== '[object Date]'
function isNonNullObject(value) {
return !!value && typeof value === 'object'
}

function isNotSpecial(value) {
var stringValue = Object.prototype.toString.call(value);

return stringValue !== '[object RegExp]'
&& stringValue !== '[object Date]'
}

function emptyTarget(val) {
return Array.isArray(val) ? [] : {}
}

function cloneIfNecessary(value, optionsArgument) {
var clone = optionsArgument && optionsArgument.clone === true
return (clone && isMergeableObject(value)) ? deepmerge(emptyTarget(value), value, optionsArgument) : value
var clone = optionsArgument && optionsArgument.clone === true;
return (clone && index$2(value)) ? deepmerge(emptyTarget(value), value, optionsArgument) : value
}

function defaultArrayMerge(target, source, optionsArgument) {
var destination = target.slice()
var destination = target.slice();
source.forEach(function(e, i) {
if (typeof destination[i] === 'undefined') {
destination[i] = cloneIfNecessary(e, optionsArgument)
} else if (isMergeableObject(e)) {
destination[i] = deepmerge(target[i], e, optionsArgument)
destination[i] = cloneIfNecessary(e, optionsArgument);
} else if (index$2(e)) {
destination[i] = deepmerge(target[i], e, optionsArgument);
} else if (target.indexOf(e) === -1) {
destination.push(cloneIfNecessary(e, optionsArgument))
destination.push(cloneIfNecessary(e, optionsArgument));
}
})
});
return destination
}

function mergeObject(target, source, optionsArgument) {
var destination = {}
if (isMergeableObject(target)) {
Object.keys(target).forEach(function (key) {
destination[key] = cloneIfNecessary(target[key], optionsArgument)
})
}
Object.keys(source).forEach(function (key) {
if (!isMergeableObject(source[key]) || !target[key]) {
destination[key] = cloneIfNecessary(source[key], optionsArgument)
var destination = {};
if (index$2(target)) {
Object.keys(target).forEach(function(key) {
destination[key] = cloneIfNecessary(target[key], optionsArgument);
});
}
Object.keys(source).forEach(function(key) {
if (!index$2(source[key]) || !target[key]) {
destination[key] = cloneIfNecessary(source[key], optionsArgument);
} else {
destination[key] = deepmerge(target[key], source[key], optionsArgument)
destination[key] = deepmerge(target[key], source[key], optionsArgument);
}
})
});
return destination
}

function deepmerge(target, source, optionsArgument) {
var array = Array.isArray(source);
var options = optionsArgument || { arrayMerge: defaultArrayMerge }
var arrayMerge = options.arrayMerge || defaultArrayMerge
var options = optionsArgument || { arrayMerge: defaultArrayMerge };
var arrayMerge = options.arrayMerge || defaultArrayMerge;

if (array) {
return Array.isArray(target) ? arrayMerge(target, source, optionsArgument) : cloneIfNecessary(source, optionsArgument)
Expand All @@ -26209,11 +26220,11 @@ deepmerge.all = function deepmergeAll(array, optionsArgument) {
return array.reduce(function(prev, next) {
return deepmerge(prev, next, optionsArgument)
})
}
};

return deepmerge
var index = deepmerge;

}));
module.exports = index;

},{}],384:[function(require,module,exports){
'use strict';
Expand Down
2 changes: 1 addition & 1 deletion dist/zangodb.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/zangodb.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zangodb",
"version": "1.0.3",
"version": "1.0.4",
"description": "MongoDB-like interface for HTML5 IndexedDB",
"main": "./build/src/index.js",
"typings": "./src/zangodb.d.ts",
Expand Down
6 changes: 4 additions & 2 deletions src/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,11 @@ class Db extends EventEmitter {

for (let name in this._config) {
try {
if (this._config[name]) {
if (!this._config[name]) {
idb.deleteObjectStore(name);
} else if (!idb.objectStoreNames.contains(name)) {
this._addStore(idb, name);
} else { idb.deleteObjectStore(name); }
}
} catch (error) { return cb(error); }
}
};
Expand Down

0 comments on commit f1cea70

Please sign in to comment.