ChatiumFor developersPlaygroundPricing
Sign in

HeapTableRepo.type

A string unique identifier for the table within the account's namespace.

It is formed based on the provided table name and some internal identifier.

In most standard cases, it has no practical application; however, it can be used to determine an object's association with a table by comparing it to the heapType property of the object (as an alternative to isMyRecord).

Usage/Signature

table.type
  • Return Value: string
    A string containing the identifier. The content of the string cannot be interpreted, and the format may change in the future.

Examples


Determining the type of record that the GenericLink field points to (instead of using isMyRecord).

const Orders = Heap.Table('orders', {
  customer: Heap.GenericLink(),
})
const Orgs = Heap.Table('orgs', {
  name: Heap.String(),
})
const Persons = Heap.Table('persons', {
  firstName: Heap.String(),
  lastName: Heap.String(),
})

async function logCustomerType(ctx: app.Ctx, order: typeof Orders.T): Promise<string> {
  const customer = await orders.customer.get(ctx)
  switch (customer.heapType) {
    case Orgs.type:
      ctx.log('customer is organization')
      break
    case Persons.type:
      ctx.log('customer is person')
      break
    default:
      ctx.log('customer has unknown type')
  }
}