Permalink
Browse files

fix(EntityRepository): do not assume relations exist

  • Loading branch information...
RWOverdijk committed Jan 15, 2017
1 parent 4483825 commit 3f4453871ac2641577371d53748d978905f154b0
Showing with 14 additions and 1 deletion.
  1. +14 −1 src/EntityRepository.ts
@@ -36,6 +36,15 @@ export class EntityRepository<T> {
this.mapping = Mapping.forEntity(entity);
}
/**
* Get a reference to the entity manager.
*
* @returns {Scope}
*/
protected getEntityManager(): Scope {
return this.entityManager;
}
/**
* Get a new query builder.
*
@@ -84,7 +93,11 @@ export class EntityRepository<T> {
}
if (options.populate === true) {
options.populate = Reflect.ownKeys(this.mapping.getRelations());
let relations = this.mapping.getRelations();
if (relations) {
options.populate = Reflect.ownKeys(relations);
}
} else if (typeof options.populate === 'string') {
options.populate = [options.populate];
}

0 comments on commit 3f44538

Please sign in to comment.