1.0.0 • Published 4 years ago
@omegalabs/repo-core v1.0.0
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
- Do an
npm install @seanttaylor/omega-repository-core
to install the package on your local machine. - Require the package in your project along with either a custom implementation or one of the implementations provided by the Omega Framework.
- Instantiate the repo implementation package with options (see Configuration Options below.)
- 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 |
1.0.0
4 years ago