Class: RecordContent

RecordContent

new RecordContent()

Deprecated

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

Content that is derived from diffusion.metadata.RecordContent. Contains a set of named RecordContent.Records that can be accessed directly or iterated over.

RecordContent is produced by diffusion.metadata.RecordContent#parse. It should not be constructed manually.

Deprecated:
  • Yes
Examples
// Produce a RecordContent instance from an update value
session.subscribe('my-topic', function(update) {
   var content = metadata.parse(update);

   // Access content
});
// Retrieve a specific record
var record = content.get('foo');
record.forEach(function(field) {
    // Do something with field
});
// Iterate through all records and construct data objects from field values
content.forEach(function(record) {
    var data = {
        foo : record.get('foo'),
        bar : record.fields('bar')
    };

    // Do something with data object
});

Classes

Builder
Record

Methods

forEach(iterator)

Iterate through all the records in this content instance.

The iterator function will be provided with each record instance and its index.

Parameters:
Name Type Description
iterator function The iterator function
Example
content.forEach(function(record, i) {
    // Do something with the record.
});

get(name, index)

Get a record for a given name and index. If the specified record doesn't exist, this will return undefined
Parameters:
Name Type Argument Default Description
name String The record name to retrieve
index Number <optional>
0 The record index
Returns:
RecordContent.Record The record found for the name
Examples
// Get the first named record
var record = content.get('record-name');
// Get a record by index
var record = content.get('record-name', 1);

records(name) → {RecordContent.Record}

Get all records for a specific record name.

If no name is given, this will return all records that this content instance contains.

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

Parameters:
Name Type Argument Description
name String <optional>
The record name
Returns:
[RecordContent.Record] Array of records
Type
RecordContent.Record
Examples
// Get all records
var records = content.records();
// Get all records with a specific name
var myRecords = content.records('record-name');