Namespace Resources

Namespace that represents the kinds of entities managed by @truffle/db

A number of the types defined by this namespace are useful when working with @truffle/db programmatically in TypeScript projects. In particular, see [[Resource]], [[Input]], and [[IdObject]].

Example

Using helper types to save and retrieve a source:

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

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

const { run } = Process.Run.forDb(db);

const [ { id } ]: Resources.IdObject<"sources">[] = await run(
Process.resources.load,
"sources",
[{ contents: "pragma solidity ..." }]
);

const { contents }: Resources.Resource<"sources"> = await run(
Process.resources.get,
"sources",
id,
gql`fragment Contents on Source { contents }`
);

See also [[connect]], [[Process.Run.forDb]], and [[Process.resources]].

Other

Re-exports DataModel
Re-exports Db

Generated using TypeDoc