Stats Sum Counter

QName: f:stats-sum-counter

Applied to an association to indicate that a statistics counter from one of end of the association should be aggregated up into another counter on the other end of the association.

This feature builds on the existing Node Statistics capabilities of Cloud CMS by letting you define custom sum counters from one end of an association to be applied to the other end.

Statistics counters are accumulated once on create and decremented once on delete.

Configuration

Property Type Default Read-Only Description
fromCounter text The name of the counter from which a value should be drawn.
toCounter text The name of the counter to which a value should be applied.
from text Either source to indicate the source of the association or target> to indicate the target of the association.

Stats Sum Counter Example

Suppose that you have an Article, a Person and a custom association called Likes. The idea is that when a person clicks a button in your app saying they like an article, you create a Likes association between the Person and the Article. The karma property from the person is reflected in the Article's popularity to indicate it's overall popularity with influential people.

It might look like this:

[Person] -> [Likes] -> [Article]

The person might look like:

{
    "title": "Joe Smith",
    "_type": "n:person",
    "karma": 1031
}

The article might look like:

{
    "title": "My Article",
    "body": "In this article, I will express opinions that are bound to offend those who profit from the opposing viewpoint..."
}

And the Likes association might look like this:

{
    "_features": {
        "f:stats-sum-counter": {
            "fromCounter": "karma",
            "toCounter": "popularity",
            "from": "source"
        }
    }
}

When the Like association is created between Joe Smith and the My Article node, the My Article node will have its _statistics incremented to absorb the source node's karma into its popularity counter. The My Article node would then look like this:

{
    "title": "My Article",
    "body": "In this article, I will express opinions that are bound to offend those who profit from the opposing viewpoint...",
    "_statistics": {
        "popularity": 1031
    }
}

If the Likes association were then deleted, the My Article node would adjust to this:

{
    "title": "My Article",
    "body": "In this article, I will express opinions that are bound to offend those who profit from the opposing viewpoint...",
    "_statistics": {
        "popularity": 0
    }
}