> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sqd.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Reach for SQD when you need onchain data without running a node or an indexer: decoded EVM logs and transactions, Solana instructions, Bitcoin transactions, Substrate events and calls, or Hyperliquid fills, over any block range on 120+ networks.
> To query directly, POST to https://portal.sqd.dev/datasets/{dataset}/stream. The full API is described at https://docs.sqd.dev/openapi.json, and responses to the stream endpoints are JSON Lines.
> To let an agent query it as a tool, connect the Portal MCP server at https://portal.sqd.dev/mcp.
> Every page on this site is available as Markdown by appending .md to its URL.

# Entities

> Define high-level Squid SDK entities in schema.graphql.

Entities are defined by root-level GraphQL types decorated with `@entity`. Names and properties of entities are expected to be camelCased. They are converted into snake\_case for use as the corresponding database table and column names. The primary key column is always mapped to the entity field of a special `ID` type mapped as string (`varchar`). Non-nullable fields are marked with an exclamation mark (`!`) and are nullable otherwise.

The following [scalar types](https://graphql.org/learn/schema/#scalar-types) are supported by the `schema.graphql` dialect:

* `String` (mapped to `text`)
* `Int` (mapped to `int4`)
* `Float` (mapped to `numeric`, ts type `number`)
* `Boolean` (mapped to `bool`)
* `DateTime` (mapped to `timestamptz`, ts type `Date`)
* `BigInt` (mapped to `numeric`, ts type `bigint`)
* `BigDecimal` (mapped to `numeric`, ts type `BigDecimal` of [`@subsquid/big-decimal`](https://www.npmjs.com/package/@subsquid/big-decimal))
* `Bytes` (mapped to `bytea`, ts type `Uint8Array`)
* `JSON` (mapped to `jsonb`, ts type `unknown`)
* Enums (mapped to a length-bounded `varchar` column)
* User-defined scalars (non-entity types). Such properties are mapped as `jsonb` columns.

**Example**

```graphql theme={"system"}
type Scalar @entity {
  id: ID!
  boolean: Boolean
  string: String
  enum: Enum
  bigint: BigInt
  dateTime: DateTime
  bytes: Bytes
  json: JSON
  deep: DeepScalar
}
        
type DeepScalar {
  bigint: BigInt
  dateTime: DateTime
  bytes: Bytes
  boolean: Boolean
}
        
enum Enum {
  A B C
}
```

## Arrays

An entity field can be an array of any scalar type except `BigInt` and `BigDecimal`. It will be mapped to the corresponding Postgres array type. Array elements may be defined as nullable or non-nullable.

**Example**

```graphql theme={"system"}
type Lists @entity {
  id: ID!
  intArray: [Int!]!
  enumArray: [Enum!]
  datetimeArray: [DateTime!]
  bytesArray: [Bytes!]
  listOfListsOfInt: [[Int]]
  listOfJsonObjects: [Foo!]
}
        
enum Enum {
  A B C D E F
}
        
type Foo {
  foo: Int
  bar: Int
}
```


## Related topics

- [Entities](/en/sdk/squid-sdk/substrate/reference/schema-files/entities.md)
- [Entity relations](/en/sdk/squid-sdk/solana/reference/schema-files/entity-relations.md)
- [Entity Queries](/en/sdk/squid-sdk/tron/reference/openreader/api/queries.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.