1.0.0 • Published 4 years ago

@omegalabs/repo-core v1.0.0

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
4 years ago

Repository Core

This module is intended for use with any of the repository implementations for the Omega Framework. omgea-repository-core provides a uniform interface for accessing datastores of any kind.

Implementations not included by default with Omega Framework can be added. Simply ensure that the new implementation adheres to the provided interface and you're all set.

Installation and Use

  1. Do an npm install @seanttaylor/omega-repository-core to install the package on your local machine.
  2. Require the package in your project along with either a custom implementation or one of the implementations provided by the Omega Framework.
  3. Instantiate the repo implementation package with options (see Configuration Options below.)
  4. Instantiate the omega-repository-core package, providing the repo implementation package as an argument.

For detailed explanation of the avaliable implementations, see the documentation for in its own github repository.

Example Usage

const options = {};
const inMemoryRepo = require('@seanttaylor/omega-repo-inmemory)(options);
const Repository = require('@seanttaylor/repository-core)
const beerRepo = Repository(inMemoryRepo);
const beer = {
    name: 'Indiana Pale Ale',
    kind: 'ale'
}

const result = await beerRepo.add(beer, 'beers_collection');
/*{
    error: null,
    status: 'ok',
    data: [
        {
            _id: '5e2f99c9fa38672ff424622b'
            name: 'Indiana Pale Ale',
            kind: 'ale',
            _createdAt: '2020-01-28T02:19:33Z'
        }
    ]
}*/

const searchResult = await beerRepo.findOne('5e2f99c9fa38672ff424622b', 'beers_table);
/*
    Same output as above.
*/

Currently Available Implementations.

Implementations with currently avaiable npm packages.

ImplementationRepo NameType
In-Memory@seanttaylor/omega-repo-inmemoryNoSQL
JSON@seanttaylor/omega-repo-jsonNoSQL
MongoDb@seanttaylor/omega-repo-mongodbNoSQL
SQLite3@seanttaylor/omega-repo-sqliteSQL
MySQL@seanttaylor/omega-repo-mysqlSQL