rt-pods-client-ts
v0.1.8
Published
RT-Pods TS Client
Downloads
88
Readme
rt-pods-client-ts
Rust Client for RT(Radix Tree)-Pods. RT-Pods is a RadixTree DBMS written in Rust.
Description
TypeScript client to interface with a running RT-Pods deployment.
For documentation beyond the doc comments on the methods; or how to get started with RT-Pods see the rt-pods
repository.
This mimics the Rust client so, for a overview you can also visit the full crate documentation here at docs.rs
.
Installation
npm install rt-pods-client-ts
Example Usage
import { RtPods } from "rt-pods-client-ts";
(async () => {
const rtPods = new RtPods(["127.0.0.1:1337"]);
await rtPods.createRadixTree("1337");
await rtPods.batchOperation("1337", [
{ Insert: ["/root", null] },
{ Insert: ["/root/images", null] },
{ Insert: ["/root/images/owls", null] },
{ Insert: ["/root/images/owls/snow.jpg", "data"] },
{ Insert: ["/root/images/owls/grey.jpg", null] },
]);
const searchResult = await rtPods.search("1337", "/root/", {
sort: [{ Length: "Ascending" }],
depth: 12,
limit: 24,
inclusive: false,
predictive: true,
corrective: null,
prepend_prefix: false,
});
console.log(searchResult);
// Logs:
// [
// ['images', null],
// ['images/owls', null],
// ['images/owls/snow.jpg', "data"],
// ['images/owls/grey.jpg', null],
// ]
await rtPods.remove("1337", "/root/images/owls/grey.jpg");
await rtPods.contains("1337", "/root/images/owls/grey.jpg");
await rtPods.deleteRadixTree("1337");
})();
// Cluster
const rtPods = new RtPods([
"127.0.0.1:1337",
"127.0.0.1:1338",
"127.0.0.1:1339"
]);
// It is highly recommended to at-least sync on startup
await rtPods.sync();
// Syncing with the cluster can let the client know
// about newly registered radix trees since the initial
// sync on construction and improve routing performance.
setInterval(async () => await rtPods.sync(), 60000);
Contributing
Open to any contributions, but this repository must mirror the rt-pods-client
Rust client completely; meaning any proposed changes here will need to be carried over to the next release of rt-pods-client
or any following clients for other languages.
License
MIT License
Copyright (c) 2024 Robert Lopez
See LICENSE.md
Project status
I plan to continue maintaining this project as long as I maintain rt-pods
.