Comparing version 2.0.0 to 2.0.1
@@ -0,1 +1,10 @@ | ||
2.0.1 / 2022-01-05 | ||
================== | ||
## What's Changed | ||
* fix: format numeric result by @JimmyDaddy in https://github.com/cyjake/leoric/pull/253 | ||
* fix: should still return number if value is '0.000' by @cyjake in https://github.com/cyjake/leoric/pull/254 | ||
**Full Changelog**: https://github.com/cyjake/leoric/compare/v1.15.1...v2.0.1 | ||
2.0.0 / 2021-12-28 | ||
@@ -2,0 +11,0 @@ ================== |
{ | ||
"name": "leoric", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "JavaScript Object-relational mapping alchemy", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
'use strict'; | ||
const { AGGREGATOR_MAP } = require('./contants'); | ||
const AGGREGATORS = Object.values(AGGREGATOR_MAP); | ||
/** | ||
@@ -90,4 +93,10 @@ * An extended Array to represent collections of models. | ||
const row = rows[0]; | ||
const result = row && (row[''] || row[table]); | ||
return result && result[value] || 0; | ||
const record = row && (row[''] || row[table]); | ||
const result = record && record[value]; | ||
// see https://www.w3schools.com/mysql/mysql_ref_functions.asp | ||
if (AGGREGATORS.includes(args[0].name)) { | ||
const num = Number(result); | ||
return isNaN(num) ? result : num; | ||
} | ||
return result; | ||
} | ||
@@ -94,0 +103,0 @@ } |
@@ -14,2 +14,3 @@ 'use strict'; | ||
const Raw = require('./raw'); | ||
const { AGGREGATOR_MAP } = require('./contants'); | ||
@@ -907,10 +908,2 @@ /** | ||
const AGGREGATOR_MAP = { | ||
count: 'count', | ||
average: 'avg', | ||
minimum: 'min', | ||
maximum: 'max', | ||
sum: 'sum' | ||
}; | ||
for (const aggregator in AGGREGATOR_MAP) { | ||
@@ -917,0 +910,0 @@ const func = AGGREGATOR_MAP[aggregator]; |
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
283547
50
7851