Comparing version 3.0.5 to 3.0.6
{ | ||
"name": "jembadb", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"description": "Json Embeddable Appendable Database", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -450,2 +450,3 @@ 'use strict'; | ||
type: String, | ||
count: Number, | ||
flag: Array, [{name: 'flag1', check: '(r) => r.id > 10'}, ...] | ||
@@ -461,2 +462,3 @@ hash: Array, [{field: 'field1', type: 'string', depth: 11, allowUndef: false}, ...] | ||
type: this.type, | ||
count: this.rowsInterface.getAllIdsSize(), | ||
flag: this.reducer._listFlag(), | ||
@@ -554,4 +556,13 @@ hash: this.reducer._listHash(), | ||
let found = []; | ||
if (!query.where && !query.distinct && !query.group && query.count) {//minor optimization | ||
found = [{count: this.rowsInterface.getAllIdsSize()}]; | ||
if (query.count && !query.distinct && !query.group) {//optimization | ||
if (query.where) { | ||
let count = 0; | ||
for (const id of ids) { | ||
if (this.rowsInterface.hasRow(id)) | ||
count++; | ||
} | ||
found = [{count}]; | ||
} else { | ||
found = [{count: this.rowsInterface.getAllIdsSize()}]; | ||
} | ||
} else {//full running | ||
@@ -558,0 +569,0 @@ for (const id of ids) { |
@@ -589,3 +589,3 @@ 'use strict'; | ||
} | ||
return result; | ||
return utils.cloneDeep(result); | ||
} | ||
@@ -592,0 +592,0 @@ |
@@ -649,2 +649,3 @@ 'use strict'; | ||
type: String, | ||
count: Number, | ||
flag: Array, [{name: 'flag1', check: '(r) => r.id > 10'}, ...] | ||
@@ -651,0 +652,0 @@ hash: Array, [{field: 'field1', type: 'string', depth: 11, allowUndef: false}, ...] |
@@ -45,2 +45,6 @@ 'use strict'; | ||
//--- rows interface | ||
hasRow(id) { | ||
return this.blockIndex.has(id); | ||
} | ||
async getRow(id) { | ||
@@ -47,0 +51,0 @@ const block = this.blockList.get(this.blockIndex.get(id)); |
@@ -9,2 +9,6 @@ 'use strict'; | ||
//--- rows interface | ||
hasRow(id) { | ||
return this.rows.has(id); | ||
} | ||
async getRow(id) { | ||
@@ -11,0 +15,0 @@ return this.rows.get(id); |
181885
4790