StoreObjectMutable interface

A JavaScript object implementing the StoreObjectMutable interface is an object in the Object Store which can be modified, then saved back to the store.

StoreObjectMutable objects also implement the StoreObject interface.

Construction

Use O.object() or mutableCopy() on StoreObject objects.

Interface

acts as StoreObject

All properties and functions in the StoreObject interface are implemented.

function save(labelChanges)

Creates or updates the object in the store.

labelChanges is optional, and if present, is used to add or remove labels from the defaults, or those specified when calling O.object(). If you only want to change the labels, use relabel() instead.

function append(value, desc, qual, ext)

Append a value to the object, with the specified desc from the schema ATTR constants. qual can be omitted, or use QUAL["std:qualifier:null"] to specify no qualifier. ext is optional – if supplied it must be an attribute extension object returned by the newAttributeGroup method.

The value can be:

Type Notes
Ref Link to another object
StoreObject ref property used for linking to the object
Text Any text object created with O.text()
String Automatically converted into a Text
DateTime Variable precision date and time
Date Automatically converted into a DateTime with Day precision
Numeric types Numbers in JavaScript are always floating point, so if the value represents an integer, it is converted to an integer value in the object store. Otherwise a floating point value is stored. See note below.

Use appendWithIntValue() if you want to be absolutely sure you’re adding an integer, or appendWithFloatValue() if you’re intending to add floating point values.

function appendWithIntValue(value, desc, qual, ext)

As append(), but with a workaround for JavaScript’s unhelpful use of floating point numbers for all numeric values.

value must be a number, and is converted into an integer value before appending to the object.

function appendWithFloatValue(value, desc, qual, ext)

As append(), but for numeric values only, and without the automatic conversion of floating point values to integers when they represent an integer value.

value must be a number, and is converted into an double floating point before appending to the object.

function appendType(value, qual, ext)

Shortcut for append(value, ATTR["dc:attribute:type"], qual, ext)

function appendTitle(value, qual, ext)

Shortcut for append(value, ATTR["dc:attribute:title"], qual, ext)

function appendParent(value, qual, ext)

Shortcut for append(value, ATTR["std:attribute:parent"], qual, ext)

function remove(desc, qual, iterator)

Remove zero or more values from the object. desc is required, qual can be omitted to specify any qualifier (If QUAL["std:qualifier:null"] is used for qual, it will only remove values without a qualifier).

If an iterator is passed as the last argument, it will be called with (value, desc, qual) arguments. If it returns true, the value will be deleted.

function newAttributeGroup(groupDesc, groupId)

Returns a new AttributeExtension object for this groupDesc. Optionally you can provide a groupId to be used to identify this group on the object, although this will typically only be necessary for modifying values on an object in place.

function preallocateRef()

Preallocate the ref for a new object before save() is called.

preallocateRef() will throw an exception if it is called when the ref has already been allocated, either by calling this function or save().

Returns the new ref.

Interface (computed attributes)

property willComputeAttributes

true if the object will compute attributes the next time it is saved or the platform uses attribute values.

function computeAttributesIfRequired()

If the object has been modified since attributes were last computed, call the hComputeAttributes hook to compute the attributes.

There is no need to check the willComputeAttributes property first; this method only does work if it is actually required.

You only need to call this method when you are working with mutable store objects and are accessing computed attributes.

Returns this store object.

function computeAttributesForced()

Like computeAttributesIfRequired(), but computes attributes even if the object hasn’t been marked as requiring an update to computed attributes.

Returns this store object.

function setWillComputeAttributes(willCompute)

Overrides the normal marking of objects as requiring attributes to be computed.

If willCompute is true, attributes will be computed when next required.

If willCompute is false, the object will be marked as not requiring attributes to be computed.

Returns this store object.