Comparing version 0.1.29 to 0.1.30
{ | ||
"name": "lokijs", | ||
"version": "0.1.29", | ||
"version": "0.1.30", | ||
"description": "A document oriented javascript in-memory database", | ||
@@ -27,8 +27,6 @@ "homepage": "http://lokijs.org", | ||
"author": "Joe Minichino <joe.minichino@gmail.com>", | ||
"contributors": [ | ||
{ | ||
"name": "Dave", | ||
"email": "admin@obeliskos.com" | ||
} | ||
], | ||
"contributors": [{ | ||
"name": "Dave", | ||
"email": "admin@obeliskos.com" | ||
}], | ||
"license": "BSD", | ||
@@ -46,2 +44,2 @@ "bugs": { | ||
} | ||
} | ||
} |
@@ -101,7 +101,7 @@ /** | ||
Resultset.prototype.limit = function (qty) { | ||
// if this is chained resultset with no filters applied, just we need to populate filteredrows first | ||
if (this.searchIsChained && !this.filterInitialized && this.filteredrows.length == 0) { | ||
this.filteredrows = Object.keys(this.collection.data); | ||
} | ||
// if this is chained resultset with no filters applied, just we need to populate filteredrows first | ||
if (this.searchIsChained && !this.filterInitialized && this.filteredrows.length == 0) { | ||
this.filteredrows = Object.keys(this.collection.data); | ||
} | ||
var rscopy = this.copy(); | ||
@@ -117,11 +117,11 @@ | ||
Resultset.prototype.offset = function (pos) { | ||
// if this is chained resultset with no filters applied, just we need to populate filteredrows first | ||
if (this.searchIsChained && !this.filterInitialized && this.filteredrows.length == 0) { | ||
this.filteredrows = Object.keys(this.collection.data); | ||
} | ||
// if this is chained resultset with no filters applied, just we need to populate filteredrows first | ||
if (this.searchIsChained && !this.filterInitialized && this.filteredrows.length == 0) { | ||
this.filteredrows = Object.keys(this.collection.data); | ||
} | ||
var rscopy = this.copy(); | ||
rscopy.filteredrows = rscopy.filteredrows.splice(pos); | ||
rscopy.filteredrows = rscopy.filteredrows.splice(pos); | ||
return rscopy; | ||
@@ -148,7 +148,7 @@ } | ||
Resultset.prototype.sort = function (comparefun) { | ||
// if this is chained resultset with no filters applied, just we need to populate filteredrows first | ||
if (this.searchIsChained && !this.filterInitialized && this.filteredrows.length == 0) { | ||
this.filteredrows = Object.keys(this.collection.data); | ||
} | ||
// if this is chained resultset with no filters applied, just we need to populate filteredrows first | ||
if (this.searchIsChained && !this.filterInitialized && this.filteredrows.length == 0) { | ||
this.filteredrows = Object.keys(this.collection.data); | ||
} | ||
var wrappedComparer = | ||
@@ -173,7 +173,7 @@ (function (userComparer, rslt) { | ||
Resultset.prototype.simplesort = function (propname, isdesc) { | ||
// if this is chained resultset with no filters applied, just we need to populate filteredrows first | ||
if (this.searchIsChained && !this.filterInitialized && this.filteredrows.length == 0) { | ||
this.filteredrows = Object.keys(this.collection.data); | ||
} | ||
// if this is chained resultset with no filters applied, just we need to populate filteredrows first | ||
if (this.searchIsChained && !this.filterInitialized && this.filteredrows.length == 0) { | ||
this.filteredrows = Object.keys(this.collection.data); | ||
} | ||
if (typeof (isdesc) == "undefined") isdesc = false; | ||
@@ -448,13 +448,12 @@ | ||
// if this is chained resultset with no filters applied, just return collection.data | ||
if (this.searchIsChained && !this.filterInitialized) { | ||
if (this.filteredrows.length == 0) { | ||
return this.collection.data; | ||
} | ||
else { | ||
// filteredrows must have been set manually, so use it | ||
this.filterInitialized = true; | ||
} | ||
} | ||
// if this is chained resultset with no filters applied, just return collection.data | ||
if (this.searchIsChained && !this.filterInitialized) { | ||
if (this.filteredrows.length == 0) { | ||
return this.collection.data; | ||
} else { | ||
// filteredrows must have been set manually, so use it | ||
this.filterInitialized = true; | ||
} | ||
} | ||
for (var i in this.filteredrows) { | ||
@@ -606,3 +605,3 @@ result.push(this.collection.data[this.filteredrows[i]]); | ||
this.sortDirty = false; | ||
if (this.persistent) this.resultsdirty = true; // newly sorted, if persistent we need to rebuild resultdata | ||
if (this.persistent) this.resultsdirty = true; // newly sorted, if persistent we need to rebuild resultdata | ||
} | ||
@@ -1033,3 +1032,3 @@ | ||
this.rollback(); | ||
console.error(err.message); | ||
console.error(err.message); | ||
} | ||
@@ -1044,6 +1043,20 @@ }; | ||
Collection.prototype.insert = function (doc) { | ||
doc.id = null; | ||
doc.objType = this.objType; | ||
this.add(doc); | ||
return doc; | ||
if (Array.isArray(doc)) { | ||
doc.forEach(function (d) { | ||
d.id = null; | ||
d.objType = this.objType; | ||
this.add(d); | ||
}); | ||
return doc; | ||
} else { | ||
if (typeof doc !== 'object') { | ||
throw new TypeError("Document needs to be an object"); | ||
return; | ||
} | ||
doc.id = null; | ||
doc.objType = this.objType; | ||
this.add(doc); | ||
return doc; | ||
} | ||
}; | ||
@@ -1093,3 +1106,3 @@ | ||
this.rollback(); | ||
console.error(err.message); | ||
console.error(err.message); | ||
} | ||
@@ -1164,3 +1177,3 @@ }; | ||
this.rollback(); | ||
console.error(err.message); | ||
console.error(err.message); | ||
} | ||
@@ -1217,3 +1230,3 @@ } | ||
this.rollback(); | ||
console.error(err.message); | ||
console.error(err.message); | ||
} | ||
@@ -1347,3 +1360,3 @@ }; | ||
if (this.transactional) { | ||
this.cachedData = clone(this.data, 'parse-stringify'); | ||
this.cachedData = clone(this.data, 'parse-stringify'); | ||
this.cachedIndex = this.indices; | ||
@@ -1350,0 +1363,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3928067
28486
4
27