reduct-js
TypeScript icon, indicating that this package has built-in type declarations

1.9.2 • Public • Published

ReductStore Client SDK for JavaScript

npm npm GitHub Workflow Status

The ReductStore Client SDK for JavaScript is an asynchronous HTTP client for interacting with a ReductStore instance from a JavaScript application. It is written in TypeScript and provides a set of APIs for accessing and manipulating data stored in ReductStore.

Features

  • Promise-based API for easy asynchronous programming
  • Support for ReductStore HTTP API v1.9
  • Token-based authentication for secure access to the database
  • Labeling for read-write operations and querying
  • Batch operations for efficient data processing

Getting Started

To get started with the ReductStore Client SDK for JavaScript, you'll need to have ReductStore installed and running on your machine. You can find instructions for installing ReductStore here.

Once you have ReductStore up and running, you can install the ReductStore Client SDK for JavaScript using npm:

npm i reduct-js

Then, you can use the following example code to start interacting with your ReductStore database from your JavaScript application:

const {Client} = require("reduct-js");

const client = new Client("http://127.0.0.1:8383");

const main = async () => {
    // Get or create a bucket in the database
    const bucket = await client.getOrCreateBucket("bucket");

    // Write a record to the bucket
    const timestamp = Date.now() * 1000;
    let record = await bucket.beginWrite("entry-1", timestamp);
    await record.write("Hello, World!");

    // Read the record back from the bucket
    record = await bucket.beginRead("entry-1", timestamp);
    console.log((await record.read()).toString());
};

main()
    .then(() => console.log("done"))
    .catch((err) => console.error("oops: ", err));

For more examples, see the Quick Start.

References

Package Sidebar

Install

npm i reduct-js

Weekly Downloads

45

Version

1.9.2

License

MIT

Unpacked Size

134 kB

Total Files

59

Last publish

Collaborators

  • flipback