Search code examples
nestjstypeorm-datamapper

how to get nestjs softremoved products


i'm trying to return softremoved products from db using typeorm, this is code:

  async getEndedSalesOfUser(user: User): Promise<Sales[]> {
    return await getRepository(Sales)
      .createQueryBuilder("sales")
      .leftJoin("sales.merchant", "m")
      .addSelect(["m.id"])
      .where("sales.merchant_id = :id", {id: user.id})
      .andWhere("sales.deleted_at != :deleted_at", {deleted_at: null})
      .getMany()
  }

but in the end, typeorm adds NOT NULL, can anybody tell how to do?


Solution

  • Use .withDeleted() to include non-softdeleted data from your db.