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)

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.

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

Use appendWithIntValue() if you want to add integers.

function appendWithIntValue(value, desc, qual)

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 appendType(value, qual)

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

function appendTitle(value, qual)

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

function appendParent(value, qual)

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

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 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.