EVER SDK
Developer ToolsEver PlatformForum
  • Ever SDK
  • Quick start (JavaScript)
  • Add EVER to your backend
  • Reference
    • Types and Methods
      • Modules
      • Module abi
      • Module boc
      • Module client
      • Module crypto
      • Module debot
      • Module net
      • Module processing
      • Module proofs
      • Module tvm
      • Module utils
    • Error API
    • Error Codes
    • JavaScript Reference
    • Rust Reference
  • Samples
    • JavaScript Samples
  • guides
    • Installation
      • Add SDK to your App
    • Configuration
      • Endpoint Configuration
      • Message Expiration
      • Message Retry
      • Config Reference
    • Work with contracts
      • Add Contract to your App
      • Use your own Giver
      • Deploy
      • Run on-chain
      • Run ABI Get Method
      • Run Fift Get Method
      • Query/Subscribe for messages(events)
      • Decode Messages(Event)
      • External Signing
      • Emulate Transaction
      • Estimate Fees
      • Validate address, convert address
      • Monitor Messages
      • Trace message processing with REMP
    • Crypto
      • Mnemonics and Keys
    • Queries and subscriptions
      • Use-cases
      • How to work with net module
      • net.query syntax
      • Data pagination
      • Subscribe to Updates
      • Query Collection
      • Aggregate Collection
  • For Binding Developers
    • How to work with Application Objects in binding generators
    • JSON Interface to Ton Client
  • Links
    • Ever SDK repository
    • AppKit JS documentation
Powered by GitBook
On this page
  • When you may need aggregate of collections?
  • Usage
  • About collections

Was this helpful?

  1. guides
  2. Queries and subscriptions

Aggregate Collection

Collections is an analytics API (not real-time, though it may look like one).

Not all filters and sortings are working now. Data is provided only for the past 7 days.

When you may need aggregate of collections?

If you want to apply some aggregators like COUNT, MAX, MIN, SUM, AVERAGE on some blockchain data.

Usage

const aggregationFunctionsResults = result = 
        (await client.net.aggregate_collection({
        collection: 'accounts',
        fields: [
            {
                field: "balance",
                fn: "MIN"
            },
            {
                field: "balance",
                fn: "MAX"
            }, {
                field: "balance",
                fn: "AVERAGE"
            }, {
                field: "balance",
                fn: "SUM"
            },
            {
                field: "balance",
                fn: "COUNT"
            }
        ]
    })).values;
console.log("Minimum account balance: " + aggregationFunctionsResults[0]);
console.log("Maximum account balance: " + aggregationFunctionsResults[1]);
console.log("Average balance: " + aggregationFunctionsResults[2]);
console.log("Total balance of all accounts: " + aggregationFunctionsResults[3]);
console.log("Number of accounts: " + aggregationFunctionsResults[4] + '\n');

About collections

There are a few collections with blockchain data:

  • accounts: blockchain account data;

  • transactions: transactions related to accounts;

  • messages: input and output messages related to transactions;

  • blocks: blockchain blocks.

  • block_signatures : validator block signatures

PreviousQuery CollectionNextHow to work with Application Objects in binding generators

Last updated 1 year ago

Was this helpful?

Sample:

https://github.com/everx-labs/sdk-samples/tree/master/core-examples/node-js/query
Reference