UNPKG

cloudcms-cli

Version:
87 lines (80 loc) 3.06 kB
var helper = require("../../../helper"); var AbstractCommand = require("../../abstract"); class GetDBIndexesCommand extends AbstractCommand { constructor() { super({ "group": "db", "name": "get-indexes", "description": "Gets the current set of DB indexes for a datastore", "schema": { "properties": [{ "name": "datastoreTypeId", "type": "string", "description": "Enter the data store type ID", "required": false, "default": "cluster", "args": ["datastoreTypeId", "type"] }, { "name": "datastoreId", "type": "string", "description": "Enter the data store ID", "required": false, "default": "default", "args": ["datastoreId", "id"] }, { "name": "children", "type": "boolean", "description": "Whether to index any child data stores as well", "required": false, "default": false, "args": ["children", "c"] }, { "name": "include", "type": "string", "description": "Comma-delimited regex string of paths to include", "required": false, "default": false, "args": ["includes", "include"] }, { "name": "exclude", "type": "string", "description": "Comma-delimited regex string of paths to exclude", "required": false, "default": false, "args": ["excludes", "exclude"] }, { "name": "username", "type": "string", "description": "Admin username", "required": true, "args": ["username", "u"] }, { "name": "password", "type": "string", "description": "Admin password", "required": true, "hidden": true, "args": ["password", "p"] }] } }); } handle(options, callback) { // call workhorse function var includeArray = []; var excludeArray = []; if (options.include) { includeArray = options.include.split(","); } if (options.exclude) { excludeArray = options.exclude.split(","); } helper.getDBIndexes(options.datastoreTypeId, options.datastoreId, options.children, includeArray, excludeArray, options.username, options.password, function(err) { callback(err); }); } } module.exports = GetDBIndexesCommand;