Number Types
Number types provide pre-configured numeric columns with appropriate precision and constraints.
Reference
Section titled “Reference”| Type | Expands 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) |
Example
Section titled “Example”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(),});Precision Notes
Section titled “Precision Notes”- Money: 19 digits total, 4 decimal places (handles up to quadrillions)
- Percentage: Stores
50.25for 50.25% - Rating: Stores values like
4.5out of 5 - Duration: Store seconds, convert in application layer