@ejfdelgado/ejflab-common 1.13.4 → 1.14.1

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@ejfdelgado/ejflab-common",
3
3
  "type": "commonjs",
4
- "version": "1.13.4",
4
+ "version": "1.14.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ejfdelgado/ejflab-common.git"
package/src/MyDates.js CHANGED
@@ -1,5 +1,7 @@
1
1
  const offset = new Date().getTimezoneOffset() / 60;
2
2
 
3
+ // https://www.npmjs.com/package/dateformat
4
+
3
5
  class MyDates {
4
6
  static getSelectedLanguage() {
5
7
  const urlParams = new URLSearchParams(window.location.search);
@@ -10,7 +10,8 @@ class CommandPostgres extends CommandBasic {
10
10
  const script = this.args[3];
11
11
  const destination = this.args[4];
12
12
  const postgresSrv = this.context.getSuperContext().getPostgresClient();
13
- if (action == "execute") {
13
+ const paging = action == "page";
14
+ if (["execute", "page"].indexOf(action) >= 0) {
14
15
  //console.log("Starting execute...");
15
16
  const dbIdData = SimpleObj.getValue(this.context.data, dbIdPath, null);
16
17
  let bodyData = {};
@@ -34,8 +35,24 @@ class CommandPostgres extends CommandBasic {
34
35
  for (let i = 0; i < bodyData.length; i++) {
35
36
  const payload = JSON.parse(JSON.stringify(dbIdData));
36
37
  payload.object = bodyData[i];
38
+ let { limit } = payload.object;
37
39
  payload.now = now;
38
- const result = await postgresSrv.executeFile(script, payload, client);
40
+ const result = { rows: [], rowCount: 0, command: null };
41
+ let localResult = { rows: [], rowCount: 0, command: null };
42
+ if (paging) {
43
+ if (typeof limit !== "number") {
44
+ limit = 20;
45
+ }
46
+ payload.limit = limit;
47
+ payload.offset = 0;
48
+ }
49
+ do {
50
+ localResult = await postgresSrv.executeFile(script, payload, client);
51
+ result.rows.push(...localResult.rows);
52
+ result.rowCount += localResult.rowCount;
53
+ result.command = localResult.command;
54
+ payload.offset += result.rows.length;
55
+ } while (paging && localResult.rows.length > 0);
39
56
  response.push(result);
40
57
  }
41
58
  await client.query("COMMIT");