Initial code commit
All checks were successful
Publish to Private NPM Registry / publish (push) Successful in 56s
All checks were successful
Publish to Private NPM Registry / publish (push) Successful in 56s
This commit is contained in:
commit
db22585fcb
27 changed files with 2652 additions and 0 deletions
23
README.md
Normal file
23
README.md
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# Polyglot Persistence Utilities Library
|
||||
This library is intended to provide utilities to help make creating polyglot storage / persistence implementations easier.
|
||||
|
||||
## Example Usage
|
||||
The following shows how to use the library
|
||||
|
||||
```ts
|
||||
import { createPolyglotRepository } from '@BridgemanAccessible/ba-polyglot-storage/repos';
|
||||
import { Entity } from './entity/Entity.js';
|
||||
import type { Properties } from './types/Properties.js';
|
||||
|
||||
// 1. Generate the custom class using the factory function
|
||||
const EventRepoClass = createPolyglotRepository<Entity, Properties>(Entity);
|
||||
|
||||
// 2. Export the initialization wrapper
|
||||
export const EntityRepo = async (
|
||||
db: DB = DB.getDefaultDB(),
|
||||
nosqlStorage: NoSQLStorage<any, any> = NoSQLStorage.getDefaultNoSQLStorage()
|
||||
) => {
|
||||
// Invoke the static method on the generated class
|
||||
return await EventRepoClass.getRepo(db, nosqlStorage);
|
||||
};
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue