Node

Provides scripting facilities around a Node.

Properties

Name Type Description
associations resultmap

All of the associations around a node.

attachments object

The attachments for the node

branch branch

The Branch on which this Association resides.

branchId string

The ID of the branch that this Association resides on.

changesetId string

The changeset ID on which this node resides. If the node has not yet been saved, this may be null.

childAssociations resultmap

All of the child associations around a node

children resultmap

All of the children of a node. This hands back the target nodes that are related by a:child associations against the given node.

description string

The Description of this document.

id string

The ID of this document.

parent node

The parent of a node (as related by a:child)

properties object

The properties for this document.

repository repository

The Repository on which this Association resides.

repositoryId string

The ID of the repository that this Association resides on.

title string

The Title of this document.

type string

The Type QName of the node (as a string)

typeQName qname

The Type QName of the node.

Methods

associate

Usage

void associate()

Arguments

None

Return

Type Description
void

Examples

Simple Association

In this code sample, we associate a node to a target node using the a:child association type.

var targetNode = branch.readNode("some_guid");
var association = node.associate(targetNode, "a:child");
Directed Association with Properties

In this code sample, we associate this node from a source node a:child association type and some custom properties. The custom properties are stored on the association.

var sourceNode = branch.readNode("some_guid");
var object = {
"weight": 3
};
var association = node.associate(targetNode, "a:child", "INCOMING", object);

del

Usage

void del()

Arguments

None

Return

Type Description
void

findAssociations

Usage

resultmap findAssociations()

Arguments

None

Return

Type Description
resultmap

Examples

In this code sample, we find any incoming associations for a node that are of type a:child. These associations start from a different node and point to our node.

var associations = node.findAssociations({
"direction": "INCOMING",
"type": "a:child"
});

The associations object is a key/value map where each key is the ID of an association. The value is the association itself.

for (var id in associations)
{
var association = associations[id];
logger.log("Found association: " + association.stringify(true));
}

reload

Usage

void reload()

Arguments

None

Return

Type Description
void

Examples

In this code sample, we make changes to a node and then reload to restore the original values.

// set the title to "Original Title"
node.properties.title = "Original Title";
node.save();

// change the title
node.properties.title = "Changed Title";

// reload
node.reload();

// the title is now "Original Title"
var test = (node.properties.title == "Original Title");
// test is true

remove

Usage

void remove()

Arguments

None

Return

Type Description
void

save

Usage

void save()

Arguments

None

Return

Type Description
void

Examples

In this code sample, we make changes to a node and save the changes.

node.properties.title = "The new title of my node";
node.properties.category = "red";
node.save();

stringify

Usage

string stringify()

Arguments

None

Return

Type Description
string

Examples

In this code sample, we take the JSON for the given document and produce a string representation of it.

var text = document.stringify(true);

update

Usage

void update()

Arguments

None

Return

Type Description
void