Simplified things by removing the PolyglotAdapter decorator
All checks were successful
Publish to Private NPM Registry / publish (push) Successful in 27s
All checks were successful
Publish to Private NPM Registry / publish (push) Successful in 27s
This commit is contained in:
parent
db22585fcb
commit
c658fa3822
4 changed files with 2 additions and 22 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@BridgemanAccessible/ba-polyglot-storage",
|
"name": "@BridgemanAccessible/ba-polyglot-storage",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"description": "A shared utility library to support Polyglot Storage implementations",
|
"description": "A shared utility library to support Polyglot Storage implementations",
|
||||||
"repository": "https://git.bridgemanaccessible.ca/Bridgeman-Accessible/ba-polyglot-storage",
|
"repository": "https://git.bridgemanaccessible.ca/Bridgeman-Accessible/ba-polyglot-storage",
|
||||||
"author": "Bridgeman Accessible<info@bridgemanaccessible.ca>",
|
"author": "Bridgeman Accessible<info@bridgemanaccessible.ca>",
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
import 'reflect-metadata';
|
|
||||||
|
|
||||||
/** Metadata key used to store the NoSQL adapter of an entity */
|
|
||||||
export const POLYGLOT_ADAPTER_META = Symbol('polyglot:adapter');
|
|
||||||
|
|
||||||
/** Links an Entity to its specific NoSQL Adapter class. */
|
|
||||||
export function PolyglotAdapter(adapterClass: any): ClassDecorator {
|
|
||||||
return (target) => {
|
|
||||||
Reflect.defineMetadata(POLYGLOT_ADAPTER_META, adapterClass, target);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { PartitionKey } from './PartitionKey.js';
|
import { PartitionKey } from './PartitionKey.js';
|
||||||
import { RowKey } from './RowKey.js';
|
import { RowKey } from './RowKey.js';
|
||||||
import { PolyglotAdapter } from './PolyglotAdapter.js';
|
|
||||||
import { NoSQLRetrieve } from './NoSQLRetrieve.js';
|
import { NoSQLRetrieve } from './NoSQLRetrieve.js';
|
||||||
import { NoSQLSave } from './NoSQLSave.js';
|
import { NoSQLSave } from './NoSQLSave.js';
|
||||||
|
|
||||||
export { PartitionKey, RowKey, PolyglotAdapter, NoSQLRetrieve, NoSQLSave };
|
export { PartitionKey, RowKey, NoSQLRetrieve, NoSQLSave };
|
||||||
|
|
@ -5,7 +5,6 @@ import logMessage, { LogLevel } from '@BridgemanAccessible/ba-logging';
|
||||||
|
|
||||||
import { PARTITION_KEY_META } from '../decorators/PartitionKey.js'
|
import { PARTITION_KEY_META } from '../decorators/PartitionKey.js'
|
||||||
import { ROW_KEY_META } from '../decorators/RowKey.js';
|
import { ROW_KEY_META } from '../decorators/RowKey.js';
|
||||||
import { POLYGLOT_ADAPTER_META } from '../decorators/PolyglotAdapter.js';
|
|
||||||
import { NOSQL_RETRIEVE_META } from '../decorators/NoSQLRetrieve.js';
|
import { NOSQL_RETRIEVE_META } from '../decorators/NoSQLRetrieve.js';
|
||||||
import { NOSQL_SAVE_META } from '../decorators/NoSQLSave.js';
|
import { NOSQL_SAVE_META } from '../decorators/NoSQLSave.js';
|
||||||
|
|
||||||
|
|
@ -42,13 +41,6 @@ export function createPolyglotRepository<TEntity extends IPolyglotEntity<TProps>
|
||||||
|
|
||||||
this.repo = repo;
|
this.repo = repo;
|
||||||
|
|
||||||
// Extract Adapter Linkage
|
|
||||||
const AdapterClass = Reflect.getMetadata(POLYGLOT_ADAPTER_META, this.targetConstructor);
|
|
||||||
|
|
||||||
if(!AdapterClass) {
|
|
||||||
throw new Error(`Polyglot setup failed: ${this.targetConstructor.name} is missing @PolyglotAdapter()`);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.nosql = nosqlStorage.getAdapter<TProps, any>(this.targetConstructor.name);
|
this.nosql = nosqlStorage.getAdapter<TProps, any>(this.targetConstructor.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue