Last active
August 25, 2023 13:08
-
-
Save yasu-s/c7fde35699da784169249817dc73287f to your computer and use it in GitHub Desktop.
510課題
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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