TERNOA Documentation
Learn Build
  • What is Ternoa Chain ?
  • SPECS
    • Polygon CDK zkEVM
    • Polygon AggLayer
    • Avail DA
    • Trusted Execution Environments 
  • BUILD
    • Wallets
    • RPC
    • API
    • Explorer
  • Tools
    • Staking
    • Ternoa Safe
    • TIP
  • Community
    • Ternoa.com
    • Github
    • Discord
    • Twitter
    • Medium
Powered by GitBook
On this page
  1. Build
  2. Javascript SDK
  3. Indexer
  4. Global requests

Aggregated queries

Some aggregation plugins are available to count some data. You can use them in simple queries.

If you look at the indexer playground docs and schema on the right panel, you can see some aggregate fields. They allow us to make some mathematical calculations for some specific dataNFTs. Let's keep the example to query some NFT filtered by a specific owner and calculate the total amount in CAPS for each listed NFT.

query {
  nftEntities(
    filter: {
      owner: { equalTo: "5CDGXH8Q9DzD3TnATTG6qm6f4yR1kbECBGUmh2XbEBQ8Jfa5" }
    }
  ) {
    totalCount
    aggregates {
      sum {
        priceRounded
      }
    }
    nodes {
      nftId
      owner
      creator
      collectionId
      offchainData
      priceRounded
    }
  }
}

The expected outcome will be :

...
aggregates: {
        sum: {
          priceRounded: 39900
        }
      },
...

Last updated 1 year ago