checkpoint
  • Introduction
  • Guides
    • Quickstart
    • Step-by-step setup
    • Indexing Ethereum contracts
    • Templates
    • One-to-one relations
    • BigInt and BigDecimal
    • ApolloServer usage
    • Time-travel queries
    • Advanced options
    • Media
  • Core Concepts
    • Models
    • Checkpoint configuration
    • Entity schema
    • Data writers (Starknet)
    • Data writers (EVM)
    • Internal data query
  • Use Cases
    • Snapshot X API
  • Community
    • Discord
    • Telegram
    • GitHub
Powered by GitBook
On this page
  • PostgreSQL mappings
  • Using BigInt and BigDecimal types
  • Custom decimal types

Was this helpful?

Export as PDF
  1. Guides

BigInt and BigDecimal

Checkpoint provides support for BigInt, Decimal, BigDecimal. It's also possible to define custom (or define existing) decimal types.

PostgreSQL mappings

BigInt and BigDecimal types are mapped to following PostgreSQL types by default:

  • BigInt -> bigint

  • Decimal -> decimal(10, 2)

  • BigDecimal -> decimal(20, 8)

Using BigInt and BigDecimal types

To use default (or custom) BigInt and BigDecimal type it needs to be predeclared in GraphQL schema using scalar keyword. Once it's declared it can be used as field's type.

scalar BigInt

type User {
  votes_count: BigInt
}  

Custom decimal types

It's possible to define new or to redefine existing decimal types using overrides. This file should be called overrides.json and stored in your source directory.

{
  "decimal_types": {
    "BigDecimalVP": {
      "p": 60,
      "d": 0
    }
  }
}

When you use custom decimal types your decimal types need to be static and stored in overrides.json file. This is because it's used in codegen process of ORM.

You can then pass those to Checkpoint via options:

import overridesConfig from './overrides.json';

// ...

const checkpoint = new Checkpoint(schema, {
  overridesConfig
});
PreviousOne-to-one relationsNextApolloServer usage

Last updated 3 months ago

Was this helpful?