|
13 | 13 | ## Rule Types
|
14 | 14 | The table shows excerpts only; see the ```ApiLogicProject``` (Northwind) sample for full syntax.
|
15 | 15 |
|
16 |
| -| Rule | Summary | Example | Notes | |
17 |
| -| :------------- | :------------- | :----- | :----- | |
18 |
| -| Constraint | Boolean function must be True<br>else transaction rolled back | ```row.Balance <= row.CreditLimit```<br><br>```row.Salary >= Decimal('1.20') * old_row.Salary``` | Multi-field<br>```old_row``` | |
19 |
| -| Formula | Function computes column value | ```row.UnitPrice * row.Quantity```<br><br>```row.OrderHeader.ShippedDate``` | lambda, or function<br>Parent ```(OrderHeader)``` references | |
20 |
| -| Sum | Derive parent-attribute as sum of designated child attribute; optional child qualification | ```Rule.sum(derive=Customer.Balance, as_sum_of=Order.AmountTotal,where=lambda row: row.ShippedDate is None)``` | Parent attribute can be hybrid (virtual)<br>scalable: pruning, adjustment | |
21 |
| -| Count | Derive parent-attribute as count of child rows; optional child qualification | ```Rule.count(derive=Order.OrderDetailCount, as_count_of=OrderDetail)``` | counts are useful as child existence checks | |
22 |
| -| Copy | Child value set from Parent | ```OrderDetail.ProductPrice = copy(Product.Price)``` | Unlike formula references, parent changes are not propagated<br>e.g, Order totals for Monday are not affected by a Tuesday price increase | |
23 |
| -| Event | Python Function | on insert, call ```congratulate_sales_rep``` | See [Extensibility](Logic-Why.md#extend-python) for a information on early, row and commit events | |
24 |
| -| Parent Check | Ensure Parent row exists | Orders must have a Customer | See [Referential Integrity](https://github.com/valhuber/LogicBank/wiki/Referential-Integrity) | |
25 |
| -| Allocation | Allocate a provider amount to recipients | allocate a payment to outstanding orders | See [Allocation](https://github.com/valhuber/LogicBank/wiki/Sample-Project---Allocation) for an example | |
26 |
| -| Copy Row | Create child row by copying parent | audit Employee Salary changes to EmployeeAudit | See [Rule Extensibility](https://github.com/valhuber/LogicBank/wiki/Rule-Extensibility) | |
| 16 | +| Rule | Summary | Example | Notes | |
| 17 | +| :-------------- | :----------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------- | |
| 18 | +| Constraint | Boolean function must be True<br>else transaction rolled back | ```row.Balance <= row.CreditLimit```<br><br>```row.Salary >= Decimal('1.20') * old_row.Salary``` | Multi-field<br>```old_row``` | |
| 19 | +| Formula | Function computes column value | ```row.UnitPrice * row.Quantity```<br><br>```row.OrderHeader.ShippedDate``` | lambda, or function<br>Parent ```(OrderHeader)``` references | |
| 20 | +| Sum | Derive parent-attribute as sum of designated child attribute; optional child qualification | ```Rule.sum(derive=Customer.Balance, as_sum_of=Order.AmountTotal,where=lambda row: row.ShippedDate is None)``` | Parent attribute can be hybrid (virtual)<br>scalable: pruning, adjustment | |
| 21 | +| Count | Derive parent-attribute as count of child rows; optional child qualification | ```Rule.count(derive=Order.OrderDetailCount, as_count_of=OrderDetail)``` | counts are useful as child existence checks | |
| 22 | +| Copy | Child value set from Parent | ```OrderDetail.ProductPrice = copy(Product.Price)``` | Unlike formula references, parent changes are not propagated<br>e.g, Order totals for Monday are not affected by a Tuesday price increase | |
| 23 | +| Event | Python Function | on insert, call ```congratulate_sales_rep``` | See [Extensibility](Logic-Why.md#extend-python) for a information on early, row and commit events | |
| 24 | +| Parent Check | Ensure Parent row exists | Orders must have a Customer | See [Referential Integrity](https://github.com/valhuber/LogicBank/wiki/Referential-Integrity) | |
| 25 | +| Allocation | Allocate a provider amount to recipients | allocate a payment to outstanding orders | See [Allocation](https://github.com/valhuber/LogicBank/wiki/Sample-Project---Allocation) for an example | |
| 26 | +| Copy Row | Create child row by copying parent | audit Employee Salary changes to EmployeeAudit | See [Rule Extensibility](https://github.com/valhuber/LogicBank/wiki/Rule-Extensibility) | |
| 27 | +| Request Pattern | Create Row to run service, per logic | MCP request: _"find the overdue orders, and send an email offering a discount"_ | See [MCP Send Mail](Integration-MCP.md#3a-logic-request-pattern) | |
27 | 28 |
|
28 | 29 |
|
29 | 30 |
|
|
0 commit comments