@ocap/indexdb-memory 1.30.10 → 1.30.12

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/esm/db/base.mjs CHANGED
@@ -169,7 +169,7 @@ var LocalBaseIndexDB = class extends BaseIndexDB {
169
169
  const query = getCollection(this.account).chain();
170
170
  const pagination = formatPagination({
171
171
  paging,
172
- defaultSortField: "balance",
172
+ defaultSortField: tokenAddress ? "balance" : "renaissanceTime",
173
173
  supportedSortFields: [
174
174
  "genesisTime",
175
175
  "renaissanceTime",
@@ -177,6 +177,7 @@ var LocalBaseIndexDB = class extends BaseIndexDB {
177
177
  "moniker"
178
178
  ]
179
179
  });
180
+ if (pagination.order.field === "balance" && !tokenAddress) throw new Error("tokenAddress is required when order.field is balance");
180
181
  debug("listTopAccounts", {
181
182
  tokenAddress,
182
183
  paging,
package/lib/db/base.cjs CHANGED
@@ -173,7 +173,7 @@ var LocalBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
173
173
  const query = getCollection(this.account).chain();
174
174
  const pagination = (0, _ocap_indexdb.formatPagination)({
175
175
  paging,
176
- defaultSortField: "balance",
176
+ defaultSortField: tokenAddress ? "balance" : "renaissanceTime",
177
177
  supportedSortFields: [
178
178
  "genesisTime",
179
179
  "renaissanceTime",
@@ -181,6 +181,7 @@ var LocalBaseIndexDB = class extends _ocap_indexdb.BaseIndexDB {
181
181
  "moniker"
182
182
  ]
183
183
  });
184
+ if (pagination.order.field === "balance" && !tokenAddress) throw new Error("tokenAddress is required when order.field is balance");
184
185
  debug$1("listTopAccounts", {
185
186
  tokenAddress,
186
187
  paging,
@@ -1,14 +1,14 @@
1
1
  import LocalBaseIndexDB from "./base.cjs";
2
2
  import { IIndexDB, IIndexTable, IndexTableTypeMap } from "@ocap/types";
3
3
  import { md5 } from "@ocap/util/lib/md5";
4
- import Loki from "lokijs";
4
+ import Lokijs from "lokijs";
5
5
 
6
6
  //#region src/db/index.d.ts
7
7
  declare class MemoryIndexDB extends LocalBaseIndexDB implements IIndexDB {
8
8
  name: string;
9
9
  version: string;
10
10
  md5: typeof md5;
11
- db: Loki;
11
+ db: Lokijs;
12
12
  tx: IIndexTable<IndexTableTypeMap['tx']>;
13
13
  account: IIndexTable<IndexTableTypeMap['account']>;
14
14
  asset: IIndexTable<IndexTableTypeMap['asset']>;
@@ -1,18 +1,18 @@
1
1
  import { BaseIndex } from "@ocap/indexdb";
2
2
  import { IIndexTable } from "@ocap/types";
3
- import Loki from "lokijs";
3
+ import Lokijs from "lokijs";
4
4
 
5
5
  //#region src/table/base.d.ts
6
6
  type UniqueIndex = string | string[];
7
7
  declare class MemoryIndex<T = unknown> extends BaseIndex<T> implements IIndexTable<T> {
8
- collection: Loki.Collection<T & Record<string, unknown>>;
8
+ collection: Lokijs.Collection<T & Record<string, unknown>>;
9
9
  /**
10
10
  * @param name table name
11
11
  * @param uniqIndex primary key(s)
12
12
  * @param db LokiJS database instance
13
13
  */
14
- constructor(name: string, uniqIndex: UniqueIndex, db: Loki);
15
- count(...args: Parameters<Loki.Collection['count']>): number;
14
+ constructor(name: string, uniqIndex: UniqueIndex, db: Lokijs);
15
+ count(...args: Parameters<Lokijs.Collection['count']>): number;
16
16
  _insert(row: Record<string, unknown>): T & Record<string, unknown>;
17
17
  _get(key: string | Record<string, unknown>): (T & Record<string, unknown>) | null;
18
18
  _update(key: string | Record<string, unknown>, updates: Record<string, unknown>): T & Record<string, unknown>;
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.30.10",
4
+ "version": "1.30.12",
5
5
  "type": "module",
6
6
  "author": "wangshijun <shijun@arcblock.io> (https://www.arcblock.io)",
7
7
  "bugs": {
@@ -78,10 +78,10 @@
78
78
  },
79
79
  "gitHead": "87990c8b5e215107fc587c1ced0d6b3e2cd2483e",
80
80
  "dependencies": {
81
- "@arcblock/did": "1.30.10",
82
- "@ocap/indexdb": "1.30.10",
83
- "@ocap/types": "1.30.10",
84
- "@ocap/util": "1.30.10",
81
+ "@arcblock/did": "1.30.12",
82
+ "@ocap/indexdb": "1.30.12",
83
+ "@ocap/types": "1.30.12",
84
+ "@ocap/util": "1.30.12",
85
85
  "debug": "^4.4.3",
86
86
  "lodash": "^4.17.23",
87
87
  "lokijs": "^1.5.12"