@itexpert-dev/keyvalue-cli
KeyValueStore service tools
Last updated a year ago by itexpert-dev .
MIT · Original npm · Tarball · package.json
$ cnpm install @itexpert-dev/keyvalue-cli 
SYNC missed versions from official npm registry.

KeyValueStore Migration Tool

Getting started

  1. Install via npm
$ npm install --global @itexpert-dev/keyvalue-cli
  1. Run kvs --help in terminal for help
  2. To use most of the commands you need config-file. ./kvs.json is used by default. You can change the path with --config option. For the list of available options see Config section below.

Features

See kvs --help for the list of available commands. See kvs <command> --help for additional information about the command.

  • run - Runs migration scripts in specified directory
  • test - Checks if specified service can execute without errors. If JSON Schema provided with the script, test also checks if produced result match the schema.
  • sample - Prints random value from given set.
  • show - Prints all keys in given set or key-value if full key is specified
  • history-down - Removes all set migration history after specified version (exclusive).
  • history-show - Shows migration history of a given set.

Config

Available options:

  • host (required) - KeyValueStore service address
  • auth (required) - KeyValueStore authentication method
    • schema - HTTP authentication schema (e.g. Bearer or Basic)
    • value - HTTP authentication value (e.g. token or basic credentials)
{
    "host": "http://localhost:6480",
    "auth": {
        "schema": "Bearer",
        "value": "token"
    }
}

Samples

Basic script

// Script is executed in Node environment,
// so no `export` syntax, use `module.exports` instead.
module.exports.view = {
    // Migrated set name
    set: 'view',

    // Script version
    version: '0.1.0',

    // Function to transform one key-value from specified set.
    // If same key-value, null or undefined returned, key-value stays in the store stays the same.
    // If if `{key, value: null}` is returned, key-value is removed from the store.
    map({key, value}) {
        return {key, value};
    }
};

JSON Schema for validation

const stringField = {type: 'string'};
module.exports.view = {
    set: 'view',
    version: '0.1.0',
    map({key, value}) {
        value = {'a': 123};
        return {key, value};
    },
    schema: {
        type: 'object',
        required: ['data'],
        properties: {
            data: {
                type: 'object',
                properties: {
                    id: stringField,
                    name: stringField,
                    isShared: {type: 'boolean'},
                    fields: {
                        type: 'array',
                        item: stringField
                    }
                }
            }
        },
        additionalProperties: true
    }
};

Current Tags

  • 0.1.0                                ...           latest (a year ago)

2 Versions

  • 0.1.0                                ...           a year ago
  • 0.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 4
Last Day 0
Last Week 2
Last Month 4
Dependencies (4)
Dev Dependencies (8)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |