Class: UpdateConstraint

diffusion.topicUpdate. UpdateConstraint

new UpdateConstraint()

A constraint to be applied to an update operation or the creation of an update stream.

Constraints describe a condition that must be satisfied for an operation to succeed. Constraints can be applied to the setting of a value or creation of an update stream. Constraints are only evaluated on the server.

The constraints are evaluated using the:

  • active session locks

  • existence of the topic

  • current value of the topic

The value of a topic can be described in several ways. The value can be described as an exact value, a partial value or an unset value.

Constraints can be composed with one another. It is only possible to construct logical ANDs of constraints. Constraints can only be composed if the resulting constraint is satisfiable. Multiple session locks can be held but a topic can only have a single value. Constraints specifying multiple topic values cannot be constructed.

Constraints can be created using a diffusion.topicUpdate.UpdateConstraintFactory, an instance of which can be obtained using update constraints. For example:


var factory = diffusion.updateConstraints();
var constraint = factory.locked(lock).and(factory.value(expectedValue));

Since:
  • 6.2

Methods

and(other) → {diffusion.topicUpdate.UpdateConstraint}

Returns a composed constraint that represents a logical AND of this constraint and another.

If the composed constraint would be unsatisfiable, an Error is thrown.

Parameters:
Name Type Description
other diffusion.topicUpdate.UpdateConstraint

a constraint that will be logically-ANDed with this constraint

Returns:

a composed constraint that represents a logical AND of this constraint and the other constraint

Type
diffusion.topicUpdate.UpdateConstraint