Class: Record

RecordContent. Record

new Record()

Deprecated

As of 6.0, RecordContent is deprecated. Instead, use the RecordV2 Data Type for record-based values.

A set of values that can be accessed directly or iterated over. A record may be accessed via RecordContent methods.

The structure and type of values is defined by a diffusion.metadata.RecordContent.Record definition.

Deprecated:
  • Yes
Examples
// Get values directly from the record
var foo = record.get('foo');
var bar = record.get('bar');
// Iterate over all values
record.forEach(function(value) {
    console.log(value);
});

Methods

fields(name)

Get all values for a specific field name.

If no name is given, this will return all field values that this record contains.

If no values exist for the given name, this will return an empty array.

Parameters:
Name Type Argument Description
name String <optional>
The field name
Returns:
Object[] The values
Examples
// Get all fields
var fields = content.fields();
// Get all values for a specific field name
var myFields = content.fields('field-name');

forEach(iterator)

Iterate through all the values in this record. The iterator function will be called with each field and its index.
Parameters:
Name Type Description
iterator function The iterator function
Example
record.forEach(function(field, i) {
    // Do something with the field.
});

get(name, index) → {Object}

Get the value for a given field name. An optional index may be provided if the metadata allows for multiple values under this field.

If the value doesn't exist, this will return undefined.

Parameters:
Name Type Argument Default Description
name String The field name
index Number <optional>
0 The field index
Returns:
The field's value
Type
Object
Examples
// Get the first field for a name
var value = record.get('field-name');
// Get the a field value by index
var value = record.get('field-name', 2);