ChatiumFor developersPlaygroundPricing
Sign in

HeapTableRepo.findById

Returns a heap object by the provided unique identifier. Unlike getById, this method is not "strict" and returns null if there is no record with the given identifier.

Usage / Signature

const rowOrNull = await table.findById(ctx, id)

Arguments

  • ctx: app.Ctx
    The request context. Used for internal implementation and allows executing the request in the appropriate transaction.
  • id: string
    The unique identifier of the required record.

Return Value: Promise<HeapObject | null>

A Heap object, or null if the record is not found.

Examples

Fetching by Identifier

const Orgs = Heap.Table('orgs', {
  name: Heap.String(),
})
const org = await Orgs.findById(ctx, 'GfrQQ1xyYWndumSHlzp0chati')
if (org) {
  ctx.console.log(org.name)
}