JSPM

@morpho-dev/subsquid-typeorm-store

1.5.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2469
  • Score
    100M100P100Q141598F
  • License GPL-3.0-or-later

TypeORM based storage for squid mappings - Morpho fork with custom TypeORM options and rollback hooks

Package Exports

  • @morpho-dev/subsquid-typeorm-store
  • @morpho-dev/subsquid-typeorm-store/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@morpho-dev/subsquid-typeorm-store) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@morpho-dev/subsquid-typeorm-store

This package provides TypeORM based database access to squid mapping handlers. This is a Morpho-maintained fork of @subsquid/typeorm-store with additional features.

Additional Features

This fork includes the following enhancements over the upstream package:

1. Custom TypeORM Configuration

Pass custom TypeORM DataSourceOptions instead of using the default configuration:

import { TypeormDatabase } from '@morpho-dev/subsquid-typeorm-store'

const database = new TypeormDatabase({
  customTypeOrmOptions: {
    type: 'postgres',
    host: 'localhost',
    port: 5432,
    database: 'mydb',
    // ... other TypeORM options
  }
})

2. Rollback Hook

Register a callback function that executes whenever a block is rolled back:

import { TypeormDatabase } from '@morpho-dev/subsquid-typeorm-store'

const database = new TypeormDatabase({
  rollbackHook: async (blockHeight: number) => {
    console.log(`Block ${blockHeight} was rolled back`)
    // Perform custom cleanup or notification logic
  }
})

Installation

npm install @morpho-dev/subsquid-typeorm-store

Usage

This package is fully compatible with the upstream @subsquid/typeorm-store API. You can use it as a drop-in replacement:

import { TypeormDatabase } from '@morpho-dev/subsquid-typeorm-store'

const database = new TypeormDatabase({
  supportHotBlocks: true,
  isolationLevel: 'SERIALIZABLE',
  stateSchema: 'squid_processor',
})

await database.connect()

Upstream

Based on @subsquid/typeorm-store v1.5.1

License

GPL-3.0-or-later