open-index/open-npm huggingface dataset:
npm package: @ocap/indexdb-dynamodb
Description: OCAP indexdb adapter that uses DynamoDB as backend
Author: wangshijun
Latest version: 0.6.8

# [**@ocap/indexdb-dynamodb**](https://github.com/arcblock/ocap-js)

[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

> OCAP indexdb adapter that stores data in dynamodb

## Install

```sh
npm install @ocap/indexdb-dynamodb
// or
yarn add @ocap/indexdb-dynamodb
```

## Usage

```js
const DynamoIndexDB = require('@ocap/indexdb-dynamodb');

const indexdb = new DynamoIndexDB({
  clientOptions: {
    region: 'us-west-2',
    endpoint: 'http://localhost:8000',
    credentials: {
      accessKeyId: 'xxx',
      secretAccessKey: 'yyy',
    },
  },
});
```

## Examples

[./examples](./examples) 是一些列子, 默认使用的是本地实例，可以修改 [./examples/.env](./examples/.env) 中的配置, 运行方法:

```bash
node transactions.js insert # 插入数据
node transactions.js read # 读取一条数据
node transactions.js read [id] # 读取一条数据
# ...
```
npm package: @ocap/indexdb-elasticsearch
Description: OCAP indexdb adapter that uses elasticsearch as backend
Author: wangshijun
Latest version: 1.28.6

# [**@ocap/indexdb-elasticsearch**](https://github.com/arcblock/blockchain)

[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

> OCAP indexdb adapter that stores data in elasticsearch

## Install

```sh
npm install @ocap/indexdb-elasticsearch
// or
pnpm install @ocap/indexdb-elasticsearch
```

## Usage

```js
const ESIndexDB = require('@ocap/indexdb-elasticsearch');

const indexdb = new ESIndexDB({
  tokenLength: 28,
  endpoint: process.env.ES_ENDPOINT,
  auth:
    process.env.ES_USERNAME && process.env.ES_PASSWORD
      ? {
          username: process.env.ES_USERNAME,
          password: process.env.ES_PASSWORD,
        }
      : null,
  prefix: 'dev',
  requestTimeout: 30000,
});
```

**If you run this in production please set `ES_SHARD_COUNT` and `ES_REPLICA_COUNT` properly to achieve better reliability and performance**

## Run test

Create a file: `indexdb/elasticsearch/.env.test`, and input:

```ini
ES_ENDPOINT=<elasticsearch endpoint>
ES_USERNAME=<elasticsearch username>
ES_PASSWORD=<elasticsearch password>
```
npm package: @ocap/indexdb-fs
Description: OCAP indexdb adapter that uses file system as backend
Author: wangshijun
Latest version: 1.29.4

# [**@ocap/indexdb-fs**](https://github.com/arcblock/blockchain)


> OCAP indexdb adapter that stores data on disk through lokijs

## Install

```sh
npm install @ocap/indexdb-fs
// or
bun install @ocap/indexdb-fs
```

## Usage

```js
const FsIndexDB = require('@ocap/indexdb-fs').default;

const indexdb = new FsIndexDB(os.tmpdir());
```
npm package: @ocap/indexdb-memory
Description: OCAP indexdb adapter that uses memory as backend, just for test purpose
Author: wangshijun
Latest version: 1.29.24

# [**@ocap/indexdb-memory**](https://github.com/arcblock/blockchain)


> OCAP indexdb adapter that stores data in memory through lokijs

## Install

```sh
npm install @ocap/indexdb-memory
// or
bun install @ocap/indexdb-memory
```

## Usage

```js
const MemoryIndexDB = require('@ocap/indexdb-memory').default;

const indexdb = new MemoryIndexDB();
```
npm package: @ocap/indexdb-sqlite
Description: OCAP indexdb adapter that uses SQLite as backend
Author: wangshijun
Latest version: 1.29.24

# [**@ocap/indexdb-sqlite**](https://github.com/arcblock/blockchain)

> OCAP indexdb adapter that uses SQLite as backend via [Kysely](https://kysely.dev/)

## Install

```sh
npm install @ocap/indexdb-sqlite
// or
bun install @ocap/indexdb-sqlite
```

## Usage

### In-Memory Mode

For testing or ephemeral data:

```js
const SqliteIndexDB = require('@ocap/indexdb-sqlite').default;

const indexdb = new SqliteIndexDB({ filename: ':memory:' });
await indexdb.initialize();

// Use indexdb...
await indexdb.tx.insert({ hash: 'abc123', sender: 'z1...' });

// Close when done
await indexdb.close();
```

### File Mode

For persistent storage:

```js
const SqliteIndexDB = require('@ocap/indexdb-sqlite').default;

const indexdb = new SqliteIndexDB({ filename: '/path/to/indexdb.sqlite' });
await indexdb.initialize();

// Data persists across restarts
```

## Features

- WAL mode enabled by default for better concurrent read performance
- Automatic migrations on initialization
- Generated columns for big number sorting (balances up to 24+ digits)
- Full-featured list methods with filtering, pagination, and sorting
- All 12 index tables: tx, account, asset, token, factory, stake, delegation, rollup, etc.

## Big Number Sorting

SQLite cannot natively sort numeric strings as numbers. This adapter uses generated columns to handle large balance values (commonly found in blockchain applications):

```sql
-- Accounts with balances like "99999999999999999999" sort correctly
SELECT * FROM account ORDER BY balance_sort DESC;
```

## API

### Constructor Options

```typescript
interface SqliteIndexDBOptions {
  filename: string;  // ':memory:' or file path
}
```

### Methods

- `initialize()` - Run migrations and prepare database
- `close()` - Close database connection
- `listTransactions(params)` - Query transactions with filters
- `listTopAccounts(params)` - Get accounts sorted by balance
- `listAssets(params)` - Query assets by owner/factory
- `listTokens(params)` - List all tokens
- `listFactories(params)` - List asset factories
- `listStakes(params)` - Query stake records
- `listDelegations(params)` - Query delegations
- `listRollups(params)` - List rollup configurations
- `getRelatedAddresses(address)` - Find related addresses