Skip to content

Number Types

Number types provide pre-configured numeric columns with appropriate precision and constraints.

TypeExpands To
col.money()decimal(19,4) + min(0)
col.percentage()decimal(5,2) + range 0-100
col.counter()integer + default(0)
col.quantity()integer + min(0)
col.rating()decimal(2,1) + range 0-5
col.duration()integer (seconds)
schemas/catalog/product.js
export default table({
id: col.id(),
price: col.money(),
discount: col.percentage(),
stock: col.quantity(),
views: col.counter(),
rating: col.rating(),
video_length: col.duration(),
});
  • Money: 19 digits total, 4 decimal places (handles up to quadrillions)
  • Percentage: Stores 50.25 for 50.25%
  • Rating: Stores values like 4.5 out of 5
  • Duration: Store seconds, convert in application layer