@naturalcycles/datastore-lib 4.8.1 → 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.
|
@@ -107,7 +107,9 @@ export class DatastoreStreamReadable extends Readable {
|
|
|
107
107
|
this.endCursor = info.endCursor;
|
|
108
108
|
this.running = false; // ready to take more _reads
|
|
109
109
|
this.lastQueryDone = Date.now();
|
|
110
|
-
|
|
110
|
+
for (const row of rows) {
|
|
111
|
+
this.push(row);
|
|
112
|
+
}
|
|
111
113
|
if (!info.endCursor ||
|
|
112
114
|
info.moreResults === 'NO_MORE_RESULTS' ||
|
|
113
115
|
(this.originalLimit && this.rowsRetrieved >= this.originalLimit)) {
|
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)
|
|
@@ -8,10 +8,7 @@ export declare class DatastoreKeyValueDB implements CommonKeyValueDB {
|
|
|
8
8
|
cfg: DatastoreKeyValueDBCfg;
|
|
9
9
|
constructor(cfg: DatastoreKeyValueDBCfg);
|
|
10
10
|
db: DatastoreDB;
|
|
11
|
-
support:
|
|
12
|
-
increment: boolean;
|
|
13
|
-
count?: boolean;
|
|
14
|
-
};
|
|
11
|
+
support: any;
|
|
15
12
|
ping(): Promise<void>;
|
|
16
13
|
createTable(): Promise<void>;
|
|
17
14
|
getByIds(table: string, ids: string[]): Promise<KeyValueDBTuple[]>;
|
package/package.json
CHANGED
|
@@ -154,7 +154,9 @@ export class DatastoreStreamReadable<T = any> extends Readable implements Readab
|
|
|
154
154
|
this.running = false // ready to take more _reads
|
|
155
155
|
this.lastQueryDone = Date.now()
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
for (const row of rows) {
|
|
158
|
+
this.push(row)
|
|
159
|
+
}
|
|
158
160
|
|
|
159
161
|
if (
|
|
160
162
|
!info.endCursor ||
|
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
|
|