2.0.4 • Published 8 months ago

@cloud-cli/store v2.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@cloud-cli/store

A tiny abstraction of database tables

Usage

import { Model, Primary, Property, Query, Resource, Unique, Model, SQLiteDriver } from '@cloud-cli/store';

// initialize
await Resource.use(new SQLiteDriver(':memory:'));

// create a resource
@Model('user')
class User extends Resource {
  @Unique() @Primary() @Property(Number) id: number;
  @Property(String) name: string;
}

// save
const john = new User({ name: 'John' });
const id = await john.save();

// find with filters
const query = new Query<User>().where('name').is('John');
const users = await Resource.find(User, query);

// remove an item
await users[0].remove();

// find John by id
const user = new User({ id });
const john = await user.find();

Storage Drivers

SQLiteDriver:

// path to a file, or `:memory:` for in memory storage.
// if not provided, defaults to `process.env.SQLITE_DB_PATH`

const driver = new SQLiteDriver('path/to/file.db');

StoreDriver (for a JSON store):

// address of Store API to use.
// if not provided, defaults to `process.env.STORE_URL`

const driver = new StoreDriver('https://store.io/hash');
2.0.4

8 months ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.6.0

2 years ago

1.5.3

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago