@ikonintegration/ikapi 3.0.11 → 3.0.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikonintegration/ikapi",
3
- "version": "3.0.11",
3
+ "version": "3.0.15",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "module": "main.js",
@@ -20,8 +20,8 @@ export default class IKDBQueryGet extends IKDBBaseQuery {
20
20
  }
21
21
  //Check for continuation
22
22
  this.lastEvaluatedKey = resp.LastEvaluatedKey;
23
- if (resp.LastEvaluatedKey && !(this.limit > 0 && unmarshalled.length == this.limit)) {
24
- localConsole.debug('Using continuation key:', resp.LastEvaluatedKey);
23
+ if (resp.LastEvaluatedKey && !(this.limit > 0 && unmarshalled.length >= this.limit)) {
24
+ localConsole.log('Using continuation key:', resp.LastEvaluatedKey, unmarshalled.length, this.limit);
25
25
  this.exclusiveStartKey = resp.LastEvaluatedKey;
26
26
  return this.run(dbManager, unmarshalled);
27
27
  } return unmarshalled;
@@ -34,7 +34,7 @@ export default class IKDBQueryGet extends IKDBBaseQuery {
34
34
  ...(this.limit > 0 ? { Limit: this.limit - (appendingItems ? appendingItems.length : 0) } : {}),
35
35
  ...(!this.scanIndexForward ? { ScanIndexForward: false } : {}),
36
36
  };
37
- localConsole.log('Querying: ', query);
37
+ localConsole.log('Querying: ', query, appendingItems.lengthlog);
38
38
  const resp = await dbManager.connection.query(query);
39
39
  // localConsole.debug('Raw result: ', resp);
40
40
  return resp;
@@ -4,6 +4,8 @@ import Utils from './../../API/IKUtils';
4
4
  export default class IKDBQueryScan extends IKDBBaseQuery {
5
5
  constructor(optIndexName) {
6
6
  super(optIndexName);
7
+ this.limit = -1;
8
+ this.lastEvaluatedKey = null;
7
9
  }
8
10
  async run(dbManager, appendingItems) {
9
11
  const localConsole = (dbManager.transaction ? dbManager.transaction.logger : console);
@@ -16,16 +18,21 @@ export default class IKDBQueryScan extends IKDBBaseQuery {
16
18
  unmarshalled = unmarshalled.concat(appendingItems);
17
19
  }
18
20
  //Check for continuation
19
- if (resp.LastEvaluatedKey) {
21
+ this.lastEvaluatedKey = resp.LastEvaluatedKey;
22
+ if (resp.LastEvaluatedKey && !(this.limit > 0 && unmarshalled.length >= this.limit)) {
23
+ localConsole.log('Using continuation key:', resp.LastEvaluatedKey, unmarshalled.length, this.limit);
20
24
  this.exclusiveStartKey = resp.LastEvaluatedKey;
21
25
  return this.run(dbManager, unmarshalled);
22
26
  } return unmarshalled;
23
27
  } return null;
24
28
  }
25
- async rawRun(dbManager) {
29
+ async rawRun(dbManager, appendingItems) {
26
30
  const localConsole = (dbManager.transaction ? dbManager.transaction.logger : console);
27
- const query = this._rawQuery(dbManager.tableName);
28
- localConsole.log('Scanning: ', query);
31
+ const query = {
32
+ ...this._rawQuery(dbManager.tableName),
33
+ ...(this.limit > 0 ? { Limit: this.limit - (appendingItems ? appendingItems.length : 0) } : {})
34
+ };
35
+ localConsole.log('Scanning: ', query, appendingItems ? appendingItems.length : 0);
29
36
  const resp = await dbManager.connection.scan(query);
30
37
  // localConsole.debug('Raw result: ', resp);
31
38
  return resp;