djorm-db-gcp-datastore
Advanced tools
Comparing version 0.1.5-alpha.10 to 0.1.5-alpha.11
const { DatastoreFormatterBase } = require('./DatastoreFormatterBase') | ||
const { Count } = require('djorm/db/Count') | ||
@@ -7,3 +8,22 @@ class DatastoreSelectFormatter extends DatastoreFormatterBase { | ||
const [query, modifiers] = this.createModifiers(qs) | ||
return modifiers.reduce((aggr, modifier) => modifier(qs, aggr), query) | ||
const dsQuery = modifiers.reduce( | ||
(aggr, modifier) => modifier(qs, aggr), | ||
query | ||
) | ||
const count = qs.props.selection.find(item => item instanceof Count) | ||
// @HACK: Assume this is count query and add dummy postprocessor | ||
if (count) { | ||
const dsq = dsQuery | ||
.select('__key__') | ||
.limit(-1) | ||
.offset(0) | ||
dsq.postprocess = results => [ | ||
{ | ||
__djorm_cnt: results.length | ||
} | ||
] | ||
return dsq | ||
} | ||
return dsQuery | ||
} | ||
@@ -10,0 +30,0 @@ } |
@@ -38,5 +38,6 @@ const { Database } = require('djorm/db/Database') | ||
async queryDb (query) { | ||
const [result] = await this.db.runQuery(query()) | ||
return result | ||
async queryDb (configureQuery) { | ||
const query = configureQuery() | ||
const [result] = await this.db.runQuery(query) | ||
return query.postprocess ? query.postprocess(result) : result | ||
} | ||
@@ -43,0 +44,0 @@ |
{ | ||
"name": "djorm-db-gcp-datastore", | ||
"version": "0.1.5-alpha.10", | ||
"version": "0.1.5-alpha.11", | ||
"description": "Datastore bindings for djorm", | ||
@@ -31,3 +31,3 @@ "author": "Pavel Žák <pavel@zak.global>", | ||
}, | ||
"gitHead": "b062395336964f9ee176f6ccadb0ac27f2b0f521" | ||
"gitHead": "30ac54fa76fcb4ddb229f872d285e7ab3f004c4c" | ||
} |
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
11497
293