@naturalcycles/datastore-lib 4.9.0 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/datastore.db.js +3 -4
- package/package.json +1 -1
- package/src/datastore.db.ts +4 -4
package/dist/datastore.db.js
CHANGED
|
@@ -170,7 +170,7 @@ export class DatastoreDB extends BaseCommonDB {
|
|
|
170
170
|
}
|
|
171
171
|
async runQueryCount(dbQuery, opt = {}) {
|
|
172
172
|
const ds = await this.ds();
|
|
173
|
-
const q = dbQueryToDatastoreQuery(dbQuery
|
|
173
|
+
const q = dbQueryToDatastoreQuery(dbQuery, ds.createQuery(dbQuery.table), await this.getPropertyFilter());
|
|
174
174
|
const aq = ds.createAggregationQuery(q).count('count');
|
|
175
175
|
const dsOpt = this.getRunQueryOptions(opt);
|
|
176
176
|
const [entities] = await ds.runAggregationQuery(aq, dsOpt);
|
|
@@ -331,15 +331,14 @@ export class DatastoreDB extends BaseCommonDB {
|
|
|
331
331
|
const [stats] = await ds.runQuery(q);
|
|
332
332
|
return stats;
|
|
333
333
|
}
|
|
334
|
-
mapId(o
|
|
334
|
+
mapId(o) {
|
|
335
335
|
if (!o)
|
|
336
336
|
return o;
|
|
337
337
|
const r = {
|
|
338
338
|
...o,
|
|
339
339
|
id: this.getKey(this.getDsKey(o)),
|
|
340
340
|
};
|
|
341
|
-
|
|
342
|
-
delete r[this.KEY];
|
|
341
|
+
delete r[this.KEY];
|
|
343
342
|
return r;
|
|
344
343
|
}
|
|
345
344
|
// if key field exists on entity, it will be used as key (prevent to duplication of numeric keyed entities)
|
package/package.json
CHANGED
package/src/datastore.db.ts
CHANGED
|
@@ -264,7 +264,7 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
|
|
|
264
264
|
): Promise<number> {
|
|
265
265
|
const ds = await this.ds()
|
|
266
266
|
const q = dbQueryToDatastoreQuery(
|
|
267
|
-
dbQuery
|
|
267
|
+
dbQuery,
|
|
268
268
|
ds.createQuery(dbQuery.table),
|
|
269
269
|
await this.getPropertyFilter(),
|
|
270
270
|
)
|
|
@@ -395,7 +395,7 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
|
|
|
395
395
|
await this.getPropertyFilter(),
|
|
396
396
|
)
|
|
397
397
|
const dsOpt = this.getRunQueryOptions(opt)
|
|
398
|
-
const { rows } = await this.runDatastoreQuery<
|
|
398
|
+
const { rows } = await this.runDatastoreQuery<ObjectWithId>(datastoreQuery, dsOpt)
|
|
399
399
|
return await this.deleteByIds(
|
|
400
400
|
q.table,
|
|
401
401
|
rows.map(obj => obj.id),
|
|
@@ -504,13 +504,13 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
|
|
|
504
504
|
return stats
|
|
505
505
|
}
|
|
506
506
|
|
|
507
|
-
private mapId<T extends ObjectWithId>(o: any
|
|
507
|
+
private mapId<T extends ObjectWithId>(o: any): T {
|
|
508
508
|
if (!o) return o
|
|
509
509
|
const r = {
|
|
510
510
|
...o,
|
|
511
511
|
id: this.getKey(this.getDsKey(o)!),
|
|
512
512
|
}
|
|
513
|
-
|
|
513
|
+
delete r[this.KEY]
|
|
514
514
|
return r
|
|
515
515
|
}
|
|
516
516
|
|