# Function toIdObject

- toIdObject<N, R, I>(resource): Pick<R, "id"> extends I
  ? Meta.IdObject<Resources.Collections, N, R>
  : undefined | Meta.IdObject<Resources.Collections, N, R>

- Convert a given [[Resource]] to an [[IdObject]]

  #### Type Parameters

  - #### N extends Resources.CollectionName

  - #### R extends DataModel.Source | Bytecode | DataModel.Compilation | ContractInstance | DataModel.Contract | NameRecord | DataModel.Network | DataModel.Project | ProjectName | NetworkGenealogy | Resources.SavedInput<N> = CollectionProperty<"resource", Resources.Collections, N> | Resources.SavedInput<N>

  - #### I extends undefined | null | Pick<R, "id"> = undefined | null | Pick<R, "id">

  #### Parameters

  - ##### resource: I

  #### Returns Pick<R, "id"> extends I
  ? Meta.IdObject<Resources.Collections, N, R>
  : undefined | Meta.IdObject<Resources.Collections, N, R>

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

Generated using TypeDoc