UNPKG

cloudcms-cli

Version:
93 lines (88 loc) 3.58 kB
var helper = require("../../../helper"); var AbstractCommand = require("../../abstract"); class NodeRelativesCommand extends AbstractCommand { constructor() { super({ "group": "node", "name": "relatives", "description": "Retrieves the relatives of a node", "schema": { "properties": [{ "name": "repositoryId", "type": "string", "description": "Enter the repository ID", "required": true, "args": ["repository", "r"] }, { "name": "branchId", "type": "string", "description": "Enter the branch ID", "required": true, "args": ["branch", "b"] }, { "name": "nodeId", "type": "string", "description": "Enter the node ID", "required": false, "args": ["node", "n", "id"] }, { "name": "path", "type": "string", "description": "Enter the node path", "required": false, "args": ["path"] }, { "name": "associationDirection", "type": "string", "description": "Enter the direction of the association related to this node", "required": false, "default": "OUTGOING", "args": ["associationDirection", "direction"] }, { "name": "associationType", "type": "string", "description": "Enter the type of the association related to this node", "required": false, "default": "a:child", "args": ["associationType", "atype"] }, { "name": "query", "type": "string", "description": "Enter the query JSON", "required": false, "args": ["query", "q"] }, { "name": "skip", "type": "number", "description": "Enter the pagination skip", "required": false, "args": ["skip", "s"] }, { "name": "limit", "type": "number", "description": "Enter the pagination limit", "required": false, "args": ["limit", "l"] }, { "name": "sort", "type": "string", "description": "Enter the pagination sort JSON", "required": false, "args": ["sort", "x"] }] } }); } handle(options, callback) { var relativesConfig = {}; relativesConfig.type = (options.associationType ? options.associationType : "a:child"); relativesConfig.direction = (options.associationDirection ? options.associationDirection : "OUTGOING"); helper.queryNodeRelatives(options.repositoryId, options.branchId, options.nodeId, options.path, relativesConfig, options.query, options.skip, options.limit, options.sort, function(err) { callback(err); }); } } module.exports = NodeRelativesCommand;