@omegalabs/repo-core

An implementation of the Repository pattern for data persistence.

Usage no npm install needed!

<script type="module">
  import omegalabsRepoCore from 'https://cdn.skypack.dev/@omegalabs/repo-core';
</script>

README

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.

Implementation Repo Name Type
In-Memory @seanttaylor/omega-repo-inmemory NoSQL
JSON @seanttaylor/omega-repo-json NoSQL
MongoDb @seanttaylor/omega-repo-mongodb NoSQL
SQLite3 @seanttaylor/omega-repo-sqlite SQL
MySQL @seanttaylor/omega-repo-mysql SQL