Class: RecordV2Delta

diffusion.datatypes. RecordV2Delta


new RecordV2Delta()

diffusion.datatypes.RecordV2 structural delta.

A RecordV2Delta describes the differences between two diffusion.datatypes.RecordV2 values. Unlike a binary delta, a structural delta can be queried to determine its effect. The diffusion.datatypes.RecordV2Delta#changes method provides details of which values have changed.

An instance can be created from two RecordV2 values using diffusion.datatypes.RecordV2#diff(RecordV2).

RecordV2Deltas are useful for identifying small changes to complex RecordV2 values. Here's any example of how to use this class to filter interesting changes from a value stream.

var datatype = diffusion.datatypes.recordv2();

session.subscribe("topic").asType(datatype).on('value', (path, spec, newValue, oldValue) => { var schema = datatype.parseSchema(spec.properties.SCHEMA);

newValue.diff(oldValue).changes(schema).forEach((change) => {
    if (change.fieldName === "address") {
        // Do something with the changed address
        console.log(newValue.getFields());
    }
});

});

Since:
  • 6.0
Author:
  • Push Technology Limited
See:

Type Definitions


Change

Represents a single change to a Record value.

Properties:
Name Type Description
recordName String

The name of the affected record

recordIndex Number

The index of the affected record

fieldName String

The name of the affected field

fieldIndex Number

The index of the affected field

key String

Returns the string key representation of the affected item in the form recordName(recordIndex).fieldName(fieldIndex).

type String

String denoting the type of change that this represents