From a1b7e10c61a61fa5802ddd11fb5b4b2d43096222 Mon Sep 17 00:00:00 2001 From: Lewis McQuillan Date: Mon, 9 Sep 2019 15:54:17 +0100 Subject: [PATCH] fix(subcollection): subcollection registers as collection name under parent rather than field name --- src/decorators/subCollection.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/decorators/subCollection.ts b/src/decorators/subCollection.ts index df83038..c11d303 100644 --- a/src/decorators/subCollection.ts +++ b/src/decorators/subCollection.ts @@ -6,7 +6,7 @@ import { getOrCreateRepository } from '../store'; * @param config The subcollection configuration. */ export default (config: ISubCollectionConfig): Function => { - return (target: IEntity, key: string): void => { + return (target: IEntity): void => { // Get the parent based on the Entity class. const parentRepository = getOrCreateRepository(target.constructor.name); const { entity, name } = config; @@ -16,6 +16,6 @@ export default (config: ISubCollectionConfig): Function => { repository.collectionConfig = { entity, name }; repository.parent = parentRepository; repository.entity = entity; - parentRepository.subcollections.set(key, repository); + parentRepository.subcollections.set(name, repository); }; };