0.2.3 • Published 5 years ago

kv-orm-cf-workers v0.2.3

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

kv-orm-cf-workers

A Cloudflare Workers KV datastore plugin for kv-orm.

Note: Requires the latest Namespace version.

Version npm downloads npm bundle size (minified) npm bundle size (minified + gzip) License types

Installation

npm install --save kv-orm kv-orm-cf-workers

Setup

  1. Create a Namespace in Cloudflare, by either:
  2. Bind the Namespace to a variable in your script:
    • Using the UI:
      1. Navigate to the Worker Editor: Worker Editor
      2. Select your Script, and go the the Resources tab.
      3. Click + Add Binding, select your new Namespace, and click Save: Namespace_Binding
    • Using the API
    • Using a deploy tool:
  3. This makes the binded, global variable available within the Cloudflare Worker Script.

Note: It's recommended that you use an exclusive namespace for a kv-orm datastore i.e. don't manually store any data in that Namespace, at risk of having it overwritten by kv-orm.

Usage

import { BaseEntity, Column, Entity } from "kv-orm";
import { CloudflareWorkersKVDatastore } from "kv-orm-cf-workers";

// Bind a Cloudflare Namespace to a variable (see Setup above): e.g. LIBRARY

const cfWorkersKVDatastore = new CloudflareWorkersKVDatastore(LIBRARY);

@Entity(cfWorkersKVDatastore)
class Author extends BaseEntity {
  @Column()
  public firstName!: string;

  @Column()
  public lastName!: string;
}

// For more information how to then use Author, check out the kv-orm package:
// https://github.com/GregBrimble/kv-orm

Limitations

  • Investigating Relationships
    ~~-to-many Relationships are limited to 4000 instances. It may be possible to overcome this limitation by having tree-like 'spaces' to contain multiple sets of children (untested!).~~
0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago