kv-orm
kv-orm is an object-relational mapper for key-value datastores.
Warning! This package is still in active development.
Tooling & Infrastructure
Source Code
Features
-
Support for multiple key-value datastores in a single application.
import { MemoryDatastore } from "kv-orm-memory"; const libraryDatastore = new MemoryDatastore(); const applicationSecrets = new MemoryDatastore();
-
Easy construction of typed entities using Typescript.
import { BaseEntity, Column, Entity } from "kv-orm"; @Entity(libraryDatastore) class Author extends BaseEntity { @Column() public firstName!: string; @Column() public lastName!: string; // ... }
-
On-demand, lazy-loading: kv-orm won't load properties of a model until they're needed, and will do so seamlessly at the time of lookup.
let author = Author.get("bbed05da-594e-41d4-9b97-423343543e16"); // 1ms - no properties of the author have been loaded console.log(await author.firstName); // 60ms - author.firstName is fetched
-
No unnecessary reads: if a property is already in memory, kv-orm won't look it up again unless it needs to.
let author = Author.get("0486b183-270d-408a-a274-49b45c418c48"); console.log(await author.lastName); // 60ms - author.lastName is fetched console.log(await author.lastName); // 1ms - author.lastName is retrieved from memory (no lookup performed)
-
Writes and deletes are completed in the background — allowing your application to get on with what it needs to.
let author = Author.get("4bc148c5-af48-46ff-a620-3246efc69d91"); author.firstName = "Ernest"; // Do more, immediately!
Supported Datastores
- In-memory with kv-orm-memory
- Cloudflare Workers KV with kv-orm-cf-workers
If there is any other datastore that you'd like to see supported, please create an issue, or make a pull request.
Roadmap
Packages
Other
Development
- Clone this repository:
git clone git@github.com:GregBrimble/kv-orm.git
- Install the core packages:
npm install
- Setup:
lerna bootstrap
lerna run build
Linting
npm run lint && lerna run lint
And to automatically fix most problems: npm run format & lerna run format
Tests
lerna run test
Reset
To start from scratch, and get back to a working state with syslinks etc.:
lerna run clean
npm run clean:node && lerna run clean:node
npm install
lerna bootstrap
lerna run build