ChatiumFor developersPlaygroundPricing
Sign in

Heap.Money

Declares a field of type Money.

This is a non-standard type in the JSON schema. It is stored in the database as a tuple [amount, currency code], and at runtime, it is represented by an instance of a special class Money. You can read more about working with monetary fields in the relevant section of the guide.

Usage / Signature

import { Heap } from '@app/heap'
Heap.Money(options)

Arguments

  • <b id="options">options</b>: {default}
    An object with additional optional parameters for the field.

    • <b id="default">default</b>: [number, string]
      The default value for this field, only in the format of a pair [amount, international currency code]. For more information on how default values work, see Guide / Heap / Default Values.

Return Value

A JSON schema for an array field with two elements, the first being a number and the second being a three-letter string.

Examples

Monetary field with a default value of $0
const products = Heap.Table('products', {
  price: Heap.Money({ default: [0, 'USD'] }),
})