node

Functions to get, query and manipulate nodes.

Example
var nodeLib = require('/lib/xp/node');

Methods

(static) connect(params) → {RepoConnection}

Creates a connection to a repository with a given branch and authentication info.

Parameters:
Name Type Description
params object

JSON with the parameters.

Properties
Name Type Attributes Description
repoId object

repository id

branch object

branch id

user object <optional>

User to execute the callback with. Default is the current user.

Properties
Name Type Attributes Description
login string

Login of the user.

idProvider string <optional>

Id provider containing the user. By default, all the id providers will be used.

principals Array.<string> <optional>

Additional principals to execute the callback with.

Returns:

Returns a new repo-connection.

Type
RepoConnection
Example
// Connect to repo 'myRepo', branch 'master'.
var myRepo = nodeLib.connect({
    repoId: 'my-repo',
    branch: 'master',
    principals: ["role:system.admin"]
});

myRepo.create({
    _name: "myName",
    displayName: "This is brand new node"
});

(static) multiRepoConnect(params) → {MultiRepoConnection}

Creates a connection to several repositories with a given branch and authentication info.

Parameters:
Name Type Description
params object

JSON with the parameters.

Properties
Name Type Description
sources Array.<object>

array of sources to connect to

Properties
Name Type Attributes Description
repoId object

repository id

branch object

branch id

user object <optional>

User to execute the callback with. Default is the current user.

Properties
Name Type Attributes Description
login string

Login of the user.

idProvider string <optional>

Id provider containing the user. By default, all the id providers will be used.

principals Array.<string> <optional>

Additional principals to execute the callback with.

Returns:

Returns a new multirepo-connection.

Type
MultiRepoConnection
Example
// Connect to repo 'myRepo', branch 'master'.
var searchConnection = nodeLib.multiRepoConnect({
    sources: [
        {
            repoId: 'my-repo',
            branch: 'myBranch',
            principals: ["role:system.admin"]
        },
        {
            repoId: 'my-other-repo',
            branch: 'master',
            principals: ["role:system.admin"]
        }
    ]
});