diffusion
Version:
Diffusion JavaScript client
78 lines (73 loc) • 2.92 kB
JavaScript
var _interface = require('util/interface')._interface;
var Bytes = require('../bytes');
/**
* An immutable value representing a list of records.
*
* @see diffusion.datatypes.RecordV2DataType
* @class diffusion.datatypes.RecordV2
* @augments diffusion.datatypes.Binary
* @since 6.0
*/
module.exports = _interface('RecordV2', Bytes, [
/**
* Compare this value with an earlier version to calculate a structural
* delta.
*
* @param {RecordV2} original - the original value to compare with this value
* @return {RecordV2Delta} a structural delta representing the difference between the original and this value
* @function diffusion.datatypes.RecordV2#diff
*/
'diff',
/**
* Parses the content into a model based upon a specified schema.
* <P>
* This assumes that data is compatible with the schema and does not do any
* validation. There is no need to validate the data if this has been done
* on entry or at the server. However, if the data is invalid then issues
* may occur when attempting to access it.
* <P>
* If it is not certain that the data is valid then the
* {@link diffusion.datatypes.RecordV2#asValidatedModel asValidateModel} method may be used instead.
*
* @param {diffusion.datatypes.RecordV2.Schema} schema - the schema to use for parsing the data
* @return {diffusion.datatypes.RecordV2.RecordModel} an immutable model derived from the data content
* @function diffusion.datatypes.RecordV2#asModel
*/
'asModel',
/**
* Parses the content into a model based upon a specified schema.
*
* @param {diffusion.datatypes.RecordV2.Schema} schema - the schema to use for parsing the data
* @return {diffusion.datatypes.RecordV2.RecordModel} - a model derived from the content
* @function diffusion.datatypes.RecordV2#asValidatedModel
*/
'asValidatedModel',
/**
* Returns the data content as an Array of Arrays of strings.
*
* @example
* // Iterate across each record's fields
* value.asRecords().forEach((record) => {
* record.forEach((field) => {
* console.log("Field value: " + field);
* });
* });
*
* @return {Array<Array<String>>} a new mutable list where each entry represents a record within the data
* @function diffusion.datatypes.RecordV2#asRecords
*/
'asRecords',
/**
* Returns the data content as a list of fields.
* <P>
* This disregards record boundaries. If there is more than one record, they
* are concatenated to produce a list of all of the fields.
* <P>
* This method would normally only be used when it is known that there is
* only one record.
*
* @return {Array<String>} a new mutable list of all the fields
* @function diffusion.datatypes.RecordV2#asFields
*/
'asFields'
]);