Skip to content

A scaling focused distributed nosql database with good performance and strong data consistency. : still beta 🔬

License

Notifications You must be signed in to change notification settings

Uiedbook/Exabase

Repository files navigation


Exabase

Exabase

High Performant and Bottomless database

Explore APIs »

Join Community

Learn how ⬇️

Contributors npm Version Forks Stargazers

Exabase provides support for these features:

  • High performance
  • Bottomless storage.
  • Consistency and Consensus.
  • Scalability.
  • Open source

Exabase is lightweight embedded and powerful distributed database.

--

How Exabase works

Exabase achieves a high degree of efficiency by employing the following techniques.

  • Separation of concerns mechanism across tables. This allows for more efficiency by keeping each table manager in it own space.
  • Exabase make an extensive use efficient algorithms for storage and query of data.
  • Consistency and Durability in log files and other very important files is achieved through an ACID complaint data processing mechanism which is optimized for crash recovery and consistency checks out of the box.
  • Exabase achieves a high search query efficiency using a custom search indexing mechanism called Xtree, written from the ground up and great at categorical search indexing needs.

Current support runtimes.

Exabase support server-side Javascript runtime like:

  • Nodejs.
  • Bunjs.
  • Denojs.

How to get started with Exabase database.

Installation

Install Exabase right on your project using npm.

npm i exabase --save

Using Exabase

The Exabase class accepts an object argument with the following options:

Options

export type ExabaseOptions = {
  /**
   * Exabase database
   * ---
   * name  */
  name?: string,
  /**
   * Exabase database
   * ---
   * Memory log cache capacity in percentage  */
  EXABASE_MEMORY_PERCENT?: number,
};

Exabase JSON Query format

Exabase is queried with json. in the format

 {
  table: string;
  operation?: {
    dropTable?: boolean;
    createTable?: boolean;
    addIndex?: boolean;
    removeIndex?: boolean;
  }
  sort?: {
    [x in keyof Partial<Model>]: "ASC" | "DESC";
  };
  where?: {
    [field: string]: {
      eq?: any;
      lt?: any;
      gt?: any;
      lte?: any;
      gte?: any;
      like?: string;
    };
  };
  insert?: Record<string, any>;
  update?: Partial<Model>;
  delete?: boolean;
  get?: boolean;
  count?: boolean;
  skip?: number;
  take?: number;
  aggregate?: {
      [field: string]: "sum" | "avg" | "min" | "max" | "count";
  };
  consistency?: "strong" | "eventual";
};

Example syntax

const user = await db.query(
  JSON.stringify({
    table: "USER",
    insert: { name: "james bond" },
  })
);

const user2 = await db.query(JSON.stringify({ table: "USER", one: user._id }));
expect(user.name).toBe("james bond");
const user3 = (
  await db.query(
    JSON.stringify({
      table: "USER",
      search: { name: user.name },
    })
  )
)[0];
const user4 = await db.query(
  JSON.stringify({
    table: "USER",
    update: { ...user, name: "gregs pola", age: 47 },
  })
);
await db.query(JSON.stringify({ table: "USER", delete: user._id }));
const user5 = await db.query(JSON.stringify({ table: "USER", one: user._id }));

expect(user._id).toBe(user2._id);
expect(user._id).toBe(user3._id);
expect(user._id).toBe(user4._id);
expect(user4.name).toBe("greg pola");
expect(user5).toBe(undefined);

A Basic Database setup and queries.

import { Exabase } from "../dist/index.js";

const db = new Exabase();

await db.query(
  JSON.stringify({
    table: "USER",
    induce: {
      age: { type: "number", required: true, index: true },
      name: { type: "string", index: true },
      kids: {
        relationType: "MANY",
        type: "string",
        target: "CHILD",
      },
    },
  })
);

await db.query(
  JSON.stringify({
    table: "CHILD",
    induce: {
      age: { type: "number", required: true, index: true },
      name: { type: "string", index: true },
    },
  })
);

const user = await db.query(
  JSON.stringify({
    table: "USER",
    insert: {
      age: i + 20,
      name: "user name",
    },
  })
);
const kid = await db.query(
  JSON.stringify({
    table: "CHILD",
    insert: {
      age: 5,
      name: "kid name",
    },
  })
);
user.kids.push(kid);

await db.query(
  JSON.stringify({
    table: "USER",
    update: user,
  })
);

Benchmarks

This benchmark is Exabase against sqlite.

Sqlite has a tiny footprint and off course really great performance with pure acidity and relational.

cpu: Intel(R) Celeron(R) CPU 4205U @ 1.80GHz runtime: bun 1.0.0 (x64-linux)

benchmark time (avg) (min … max) p75 p99 p995

---

SELECT _ FROM "Employee" Exabase 1.39 µs/iter (1.23 µs … 3.77 µs) 1.35 µs 3.77
µs 3.77 µs SELECT _ FROM "Employee" sqlite 270.73 µs/iter (187.72 µs … 3.24 ms)
267.24 µs 1.19 ms 1.48 ms 150X faster

Log caching

Log caching is a basic LOG file level cache. this means, it stores the entire LOG(n) file of the table in memory, where n is the last active LOG file.

Apache 2.0 Licensed

Open source.

telegram group.

Contribution and License Agreement

If you contribute code to this project, you are implicitly allowing your code to be distributed under the Apache License. You are also implicitly verifying that all code is your original work.

About

A scaling focused distributed nosql database with good performance and strong data consistency. : still beta 🔬

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published