Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
feat(repository): Added support for new populated entity
  • Loading branch information
RWOverdijk committed Dec 16, 2015
1 parent 4dde58f commit 54ba646813dcea973acd8d0603872ae92e8b01f2
Showing with 16 additions and 0 deletions.
  1. +16 −0 src/repository.js
@@ -118,4 +118,20 @@ export class Repository {
getNewEntity() {
return this.entityManager.getEntity(this.resource);
}

/**
* Populate a new entity, with the (empty) associations already set.
*
* @return {Entity}
*/
getNewPopulatedEntity() {
let entity = this.getNewEntity();
let associations = entity.getMeta().fetch('associations');

for (let property in associations) {
entity[property] = this.entityManager.getRepository(associations[property]).getNewEntity();
}

return entity;
}
}

0 comments on commit 54ba646

Please sign in to comment.