Skip to content

etcd3 client which allows you to put json or array objects and get them as json-like object. You can also use client object from Etcd3 class to use it natively. It will export it.

Notifications You must be signed in to change notification settings

inceabdullah/etcd3-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

etcd3-json

Etcd supports string values. You can keep json or array objects in etcd server with being stringified and can get them parsed.

This lib exports client object from Etcd3 class to use that framework natively also.

Install

npm i etcd3-json

in test.js file can be seen an example

// You can get client object for native use
const { putValue, getValue, getAll, client } = require("./services/etcd3");

(async ()=>{
    const person = {
        name: "john",
        surname: "snow",
        age: 4
    }
    const people = [ person ]

    // Put keys
    await putValue("foo", "bar");
    // You can put object stringified
    await putValue("person", person);
    await putValue("people", people);

    // Get keys
    const fooValue = await getValue("foo");
    const personValue = await getValue("person");
    const peopleValue = await getValue("people");
    // Get all
    const all = await getAll();

    console.log({fooValue, personValue, peopleValue});
/*   expected result
    {
        fooValue: 'bar',
        personValue: { name: 'john', surname: 'snow', age: 4 },
        peopleValue: [ { name: 'john', surname: 'snow', age: 4 } ]
    }
 */
//Delete one
    await delKey("foo");
    const _fooValue = await getValue("foo");
    console.log({_fooValue})

/*  expected result
    { _fooValue: {} }
 */

    // You can use client object from Etcd3 to use natively
    await client.delete().all();
    const allAfterDel = await client.getAll();
    console.log({allAfterDel});
/*  expected result
    { allAfterDel: {} }

 */
})()

About

etcd3 client which allows you to put json or array objects and get them as json-like object. You can also use client object from Etcd3 class to use it natively. It will export it.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages