# 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]].

- Defined in packages/db/src/resources/index.ts:1

#####
Index

### Primary

CollectionName
IdObject
Input
MutableCollectionName
NamedCollectionName
Resource
toIdObject

### Other

DataModel
Db
IdFields
SavedInput

### Internal

Collections
Definition
Definitions
Workspace
definitions

## Other

### DataModel

Re-exports DataModel

### Db

Re-exports Db

Generated using TypeDoc