Technical questionAccepted answer
How can I get soft deleted entity from typeorm postgreSQL?
Jurgis
Oct 13
0 views1
I am trying to get soft deleted doc from postgreSQL database using typeorm find, findOne or query builder get/getMany methods, but it always return undefined. Is there a way to get deleted value?
By the docs it should only set a timestamp for deletedAt, and it definitely works, because I can update same record using update where from query builder.
1 answer
Accepted answer · original discussion
BunyamiN
PermalinkNov 30
I found out there is another solution. You can use the querybuilders .withDeleted() method to also return soft deleted entities.
Example
const query = await this.manager
.getRepository(FolderEntity)
.withDeleted()
.createQueryBuilder('folder')
.leftJoinAndSelect('folder.subStatus', 'status')
.getMany()
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.