# Type alias Db

Db: Meta.Db<Resources.Collections>

An instance of @truffle/db

Defines the [[Meta.Db.execute | `db.execute()`]] method, which accepts GraphQL requests and returns GraphQL responses.

See [[connect | connect()]] for how to instantiate this interface.

#### Example

    import gql from "graphql-tag";
    import { connect, Db } from "@truffle/db";

    const db: Db = connect({
      // ...
    });

    const {
      project: {
        contract: {
          id,
          abi,
          processedSource,
          callBytecode
        }
      }
    } = await db.execute(gql`
      query {
        project(id: "0x...") {
          contract(name: "MagicSquare") {
            id
            abi { json }
            processedSource {
              source { contents }
              ast { json }
            }
            callBytecode {
              bytes
              linkReferences { name length offsets }
              instructions { opcode programCounter pushData }
            }
          }
        }
      }
    `);

- Defined in packages/db/src/resources/types.ts:195

Generated using TypeDoc