Skip to content

Commit 8d679c6

Browse files
Update documentation to show multiple import styles
Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
1 parent 8e737ae commit 8d679c6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/spec/docs/formula-functions.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,23 @@ Formula fields in ObjectStack allow you to create calculated values using expres
77
Formula fields use the `expression` property in field definitions:
88

99
```typescript
10+
// Direct subpath import (Style 3)
1011
import { Field } from '@objectstack/spec/data';
1112

1213
const totalPrice = Field.formula({
1314
name: 'total_price',
1415
label: 'Total Price',
1516
expression: 'ROUND(unit_price * quantity, 2)'
1617
});
18+
19+
// Alternative: Namespace import (Style 1)
20+
import { Data } from '@objectstack/spec';
21+
22+
const discountedPrice = Data.Field.formula({
23+
name: 'discounted_price',
24+
label: 'Discounted Price',
25+
expression: 'IF(quantity > 10, price * 0.9, price)'
26+
});
1727
```
1828

1929
## Function Categories

0 commit comments

Comments
 (0)