Adds new values to the end of a variable length field list.
This can only be used for a variable multiplicity field which can only be the last field in a record and therefore the field does not need to be named.
If the record name and index are not supplied, this will add values to the last record in the model. If the model's schema does not specify a variable last field or record, an error will be thrown.
the name of the record
the index identifying the occurrence of the record
the values to add
this model
Adds a new initialized record occurrence to the end of a variable multiplicity record list.
As the only variable multiplicity record can be the last one there is no need to name the record. This method will add to the list of occurrences of the last defined record. The record will be initialized with default values appropriate to the schema definition and may then have individual field items set separately.
this model
Returns the actual number of occurrences of a named field within a specified record.
For all but variable fields this simply returns the schema defined number of occurrences of the field.
the record name
the record index
the field name
the actual number of occurrences of the field
Get a field value.
This allows an item to be addressed using a key of the form
recordName(recordIndex).fieldName(fieldIndex). Indexes may be omitted in
which case 0
is assumed.
Example:
// Get field value with record & field names and indices
const value = model.get("record", 0, "field", 0);
// Get field value with key
const value = model.get("Address.Name");
the name of the record
the index of the record
the name of the field
the index of the field
the field value
Returns the actual number of occurrences of a named record.
If the record is not variable, this is the same as the defined number of occurrences in the schema
the record name
the actual number of occurrences of the record
Removes the specified occurrence of a variable multiplicity field.
A variable multiplicity field must be the last or only field within a record and therefore the field name is not required.
the name of the record
the record index
the index of the field to remove
this model
Removes the specified occurrence of a variable multiplicity record.
A variable multiplicity record must be the last or only record within a schema and therefore the record name is not required.
the index of the record to remove
this model
Set a field value.
This allows an item to be addressed using a key of the form
recordName(recordIndex).fieldName(fieldIndex)
. Indexes may be omitted
in which case 0
is assumed.
Example:
// Get field value with record & field names and indices
var value = model.set("record", 0, "field", 0, "foo");
the name of the record
the index of the record
the name of the field
the index of the field
the value to be set
this model
This is a mutable data model of RecordV2 data based upon a Schema.
An initial version of such a model can be created from a schema using the Schema.createMutableModel method. A model created in this way will have all mandatory fields set to default values.
The model may then be updated as required and then at any time a RecordV2 object can be generated from the current state using the asValue method. The RecordV2 object may then be used to update a topic.
When values for integer or decimal type fields are supplied the values are validated and normalized. All number values will have any insignificant leading zeroes removed. A decimal value will also be rounded to its specified scale.
All mutator methods return the model so that calls can be chained.
6.0