@ocap/indexdb-memory 1.27.15 → 1.27.16

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.
Files changed (2) hide show
  1. package/lib/db/base.js +20 -1
  2. package/package.json +5 -5
package/lib/db/base.js CHANGED
@@ -6,6 +6,7 @@ const { formatPagination, formatNextPagination, formatDelegationAfterRead } = re
6
6
  const { parseDateTime } = require('@ocap/indexdb/lib/util');
7
7
  const { DEFAULT_TOKEN_DECIMAL } = require('@ocap/util/lib/constant');
8
8
  const { toChecksumAddress } = require('@arcblock/did/lib/type');
9
+ const omit = require('lodash/omit');
9
10
 
10
11
  const debug = require('debug')(require('../../package.json').name);
11
12
 
@@ -27,6 +28,7 @@ class LocalBaseIndexDB extends BaseIndexDB {
27
28
  stakeFilter = {},
28
29
  delegationFilter = {},
29
30
  tokenFactoryFilter = {},
31
+ includeItxData = false,
30
32
  } = {}) {
31
33
  const query = this.tx.collection.chain();
32
34
 
@@ -59,6 +61,7 @@ class LocalBaseIndexDB extends BaseIndexDB {
59
61
  rollups,
60
62
  stakes,
61
63
  delegations,
64
+ includeItxData,
62
65
  });
63
66
 
64
67
  if (sender && receiver) {
@@ -144,12 +147,28 @@ class LocalBaseIndexDB extends BaseIndexDB {
144
147
  query.where((x) => x.delegations.some((f) => delegations.includes(f)));
145
148
  }
146
149
 
147
- const transactions = query
150
+ let transactions = query
148
151
  .simplesort(pagination.order.field, paging.order.type === 'desc')
149
152
  .offset(pagination.cursor)
150
153
  .limit(pagination.size)
151
154
  .data();
152
155
 
156
+ // Filter out data field if includeItxData is false (default behavior for performance)
157
+ if (!includeItxData) {
158
+ transactions = transactions.map((tx) => {
159
+ if (tx.tx && tx.tx.itxJson) {
160
+ return {
161
+ ...tx,
162
+ tx: {
163
+ ...tx.tx,
164
+ itxJson: omit(tx.tx.itxJson, ['data']),
165
+ },
166
+ };
167
+ }
168
+ return tx;
169
+ });
170
+ }
171
+
153
172
  const total = query.count();
154
173
  const nextPaging = {
155
174
  cursor: pagination.cursor + transactions.length,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ocap/indexdb-memory",
3
3
  "description": "OCAP indexdb adapter that uses memory as backend, just for test purpose",
4
- "version": "1.27.15",
4
+ "version": "1.27.16",
5
5
  "author": "wangshijun <shijun@arcblock.io> (https://www.arcblock.io)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/ArcBlock/blockchain/issues",
@@ -15,7 +15,7 @@
15
15
  ],
16
16
  "devDependencies": {
17
17
  "jest": "^29.7.0",
18
- "@ocap/indexdb-test": "1.27.15"
18
+ "@ocap/indexdb-test": "1.27.16"
19
19
  },
20
20
  "homepage": "https://github.com/ArcBlock/blockchain/tree/master/indexdb/memory",
21
21
  "keywords": [
@@ -38,9 +38,9 @@
38
38
  "empty-value": "^1.0.1",
39
39
  "lodash": "^4.17.21",
40
40
  "lokijs": "^1.5.12",
41
- "@arcblock/did": "1.27.15",
42
- "@ocap/util": "1.27.15",
43
- "@ocap/indexdb": "1.27.15"
41
+ "@ocap/indexdb": "1.27.16",
42
+ "@ocap/util": "1.27.16",
43
+ "@arcblock/did": "1.27.16"
44
44
  },
45
45
  "scripts": {
46
46
  "lint": "eslint tests lib",