Skip to content

Instantly share code, notes, and snippets.

@puttputt
Created September 6, 2017 18:25
Show Gist options
  • Save puttputt/ecf9b419cf94040449a7a9cfab9e1167 to your computer and use it in GitHub Desktop.
Save puttputt/ecf9b419cf94040449a7a9cfab9e1167 to your computer and use it in GitHub Desktop.
public async deleteCompany(req: Request, res: Response, next: NextFunction) {
try {
let test = await this.service.delete(req.body.id);
res.status(200).json({});
} catch(error) {
res.status(400).json(error);
}
}
public async delete(id : number) : Promise<any> {
const companyRepository = getEntityManager().getRepository(Company);
let company = await companyRepository.findOneById(id)
let entity = await companyRepository.remove(company);
return entity;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment