ChatiumFor developersPlaygroundPricing
Sign in

Heap - Database

The built-in storage for structured data in Chatium is called Heap. Below is a simple example that illustrates the use of this storage:

import { Heap } from '@app/heap'

export const Cats = Heap.Table('cats', {
  name: Heap.String(),
  happy: Heap.Boolean(),
})

async function catsExample(ctx: app.Ctx) {
  const newCat = await Cats.create(ctx, {
    name: 'Kitty',
    happy: true,
  })
  const sortedHappyCats = await Cats.findAll(ctx, {
    where: { happy: true },
    order: 'name',
  })
  return sortedHappyCats
}

Detailed documentation on all storage APIs