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
- Heap - API for declaring tables
- Heap.Any
- Heap.Array
- Heap.AudioFile
- Heap.Boolean
- Heap.DateTime
- Heap.Enum
- Heap.File
- Heap.GenericLink
- Heap.ImageFile
- Heap.Literal
- Heap.Money
- Heap.Null
- Heap.Number
- Heap.NonEmptyString
- Heap.NonRequired
- Heap.Nullable
- Heap.Object
- Heap.Optional
- Heap.Record
- Heap.RefLink
- Heap.RegEx
- Heap.String
- Heap.Table - main method for declaring a table
- Heap.Tuple
- Heap.Union
- Heap.Undefined
- Heap.Unknown
- Heap.VideoFile
- HeapTableRepo - API for working with table data
- HeapObject - what records (rows) in the table represent
- serializableTransaction - atomic execution of a group of changes in a single transaction.