Comparing version 1.3.0 to 1.3.1
19
index.js
@@ -7,2 +7,11 @@ function CafeQueryError(message) { | ||
const assertSingle = rows => { | ||
if (!rows) { | ||
throw new CafeQueryError('Expected single result, got falsy value') | ||
} | ||
if (rows.length !== 1) { | ||
throw new CafeQueryError('Expected single result, got length: ' + rows.length) | ||
} | ||
} | ||
function CafeQuery(dataSource) { | ||
@@ -21,8 +30,3 @@ return { | ||
const [rows] = await dataSource.query(query, values) | ||
if (!rows) { | ||
throw new CafeQueryError('Expected single result, got falsy value') | ||
} | ||
if (rows.length !== 1) { | ||
throw new CafeQueryError('Expected single result, got length: ' + rows.length) | ||
} | ||
assertSingle(rows) | ||
return rows[0] | ||
@@ -43,3 +47,4 @@ }, | ||
const [rows] = await dataSource.query(query, values) | ||
return rows.length | ||
assertSingle(rows) | ||
return rows[0]['COUNT(*)'] | ||
}, | ||
@@ -46,0 +51,0 @@ query: async (query, ...values) => { |
{ | ||
"name": "cafe-query", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
2424
67