Skip to content

Instantly share code, notes, and snippets.

@yasu-s
Last active August 25, 2023 13:08
Show Gist options
  • Save yasu-s/c7fde35699da784169249817dc73287f to your computer and use it in GitHub Desktop.
Save yasu-s/c7fde35699da784169249817dc73287f to your computer and use it in GitHub Desktop.
510課題
export default class Repository<E> {
user: User;
entityClass: ObjectType<E>;
entityManager: EntityManager;
constructor(user: User, entityClass: ObjectType<E>) {
this.user = user;
this.entityClass = entityClass;
this.entityManager = getManager();
}
save = async <T extends E | E[], P extends T extends E ? E : E[]>(entity: P, transaction?: EntityManager): Promise<P> => {
if (transaction) {
return await transaction.save(entity);
}
return await this.entityManager.save(entity);
};
//他の処理
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment