DB Schema

This is the latest schema of the database at the time of writing this doc. The latest schema of the database can be explored by looking at a specific payload from a specific Collection using the code snippet at the end of this page.

// All retrieval bots share the same schema
interface {filecoin_foundation|triton_retrieval|gravity_assist|
           slingshot_retrieval|new_web_group|protocol_labs}_retrieval_bot {
  id: string;
  avg_speed_bps: number;
  avg_ttfb_ms: number;
  bitswap_retrieval_success: number;
  bitswap_retrievals: number;
  date_stamp: string;
  graphsync_retrieval_success: number;
  graphsync_retrievals: number;
  http_retrieval_success: number;
  http_retrievals: number;
  provider: string;
}

interface filfox {
  id: string;
  blocksMined: number;
  date_stamp: string;
  epoch: number;
  provider: string;
  qualityAdjPower: string;
  rawBytePower: string;
  totalRewards: string;
  weightedBlocksMined: number;
}

interface filrep {
  id: string;
  __v: number;
  date_stamp: string;
  price: string;
  provider: string;
  rank: number;
  reachability: string;
  recentDeals: number;
  verifiedPrice: string;
}

interface filscan {
  id: string;
  active_sector_count: number;
  balance: string;
  date_stamp: string;
  epoch: number;
  fault_sector_count: number;
  live_sector_count: number;
  multi_address: string;
  provider: string;
  recover_sector_count: number;
  terminated_sector_count: number;
}

interface ground_control_sp_location {
  id: string;
  __v: number;
  agentCity: string;
  agentCountry: string;
  agentLatitude: number;
  agentLongitude: number;
  agentRegion: string;
  date_stamp: string;
  latencyMs: number;
  multiaddr: string;
  provider: string;
  testId: string;
}

interface lassie_bedrock {
  id: string;
  bandwidth_bytes_sec: number;
  date_stamp: string;
  end_time: string;
  instance_id: string;
  provider: string;
  retrieval_id: string;
  start_time: string;
  storage_provider_id: string;
  success: boolean;
  time_to_first_byte_ms: number;
}

interface starboard {
  id: string;
  balance: number;
  base_tx_fee: string;
  batch_fee: string;
  blocks_mined: number;
  date_stamp: string;
  fee_debt: number;
  initial_pledge: number;
  locked_funds: number;
  miner_tip: string;
  onboarding_at: string;
  over_estimation_burn: string;
  pre_commit_deposits: number;
  provider: string;
  provider_collateral: number;
  rewards: number;
  sector_size: number;
  stat_date: string;
  win_count: number;
  windowpost_gas_fee: string;
}

export interface stfil {
  id: string;
  date_stamp: string;
  debt: string;
  debt_ratio: string;
  delegated_role: string;
  equity: string;
  liquidation_threshold: number;
  max_leverage: number;
  position: string;
  provider: string;
  stable_debt: string;
  variable_debt: string;
}

You can run the following query to see the latest schema of a Collection:

import {CollectionNames} from "@dataprograms/repdao-polybase";

for (const collectionName of CollectionNames) {
    let response
    try {
        response = await DB.collection(collectionName).where('provider', '==', provider).limit(1).get()
    } catch (e: any) {
        if (e instanceof PolybaseError) {
            console.error(`Polybase error: ${e.code} ${e.message} when retrieving ${collectionName} record for ${provider}`)
            continue
        }

        throw e
    }
    if (response.data.length === 0) {
        console.log(`No ${collectionName} record for ${provider}`)
        continue
    }
    const doc = response.data[0].data
    console.log(`${collectionName} record for ${provider}:`)
    console.log(doc)
}

Last updated