Count Rule Type
Count Rule Type
Count rules are derivation rules that calculate the number of child objects, with an optional child qualification condition (where clause). API Creator derives the parent attribute value by counting designated child rows. You can 'trigger' an event action using the state change (increase or decrease) in a child row. For example, if the count of the child transactions is greater than 100, you could archive the older rows to MongoDB.
The count rule declares an attribute to be maintained as the count of a designated child role, with an optional qualification to filter child objects. For example:
Derive orders.item_count ascount(lineitemsList)
Count rules are useful as chid existence checks. For example, you can ensure that orders have at least one line item entry using the
item_countin a (commit!) validation. When necessary, API Creator updates the value of the attribute to reflect the count of the specified attribute in the child objects. This includes the child objects you add to and remove from the parent object, as well as modifications to the child objects that change their qualification in the count. Changes to the child triggers count processing. You can view the changes in the log.
API Creator makes adjustments to recalculate the count. For instance, when you add a new (qualifying) child to the parent, the count attribute is incremented by one. The performance impact is small.
Best Practice:To maintain high performance, count values are assumed to be correct on disk. For proper operation, if you define new counts on existing data, bring your current schema into conformance by initializing those new counts using SQL tools.
For more information:
Create Count Rules
- In API Creator, select Manage, Rules, and click theCreate New Rule.
- Select the Count rule type, the entity to which it applies, and clickCreate Rule.
- ClickActivate and Closeto return to the list of rules.
The count rule is created.