Last active
April 9, 2021 07:33
-
-
Save boydaihungst/ae34f85698134cdf8198208087a41b69 to your computer and use it in GitHub Desktop.
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 abstract class RepoBase<T> extends Repository<T> { | |
async customFind(optionsOrConditions?: FindManyOptions<T> | Partial<T>) { | |
const connection = this.manager.connection; | |
const metadata = this.metadata; | |
if ( | |
metadata.deleteDateColumn && | |
optionsOrConditions && | |
'withDeleted' in optionsOrConditions && | |
!optionsOrConditions.withDeleted | |
) { | |
if (!optionsOrConditions.where) optionsOrConditions.where = {}; | |
optionsOrConditions.where[ | |
connection.driver.escape(metadata.deleteDateColumn.databaseName) | |
] = null; | |
return this.find(optionsOrConditions); | |
} | |
} | |
} | |
export class FileRepository extends RepoBase<File> { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment