Went back to using id's for deletion (for cleaner query params)

ref #13 #17
This commit is contained in:
2020-12-09 19:41:15 +01:00
parent a068c4d318
commit df5b8ac141
6 changed files with 21 additions and 15 deletions

View File

@@ -1,7 +1,7 @@
import { Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put } from 'routing-controllers';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { getConnectionManager, Repository } from 'typeorm';
import { EntityFromBody, EntityFromParam } from 'typeorm-routing-controllers-extensions';
import { EntityFromBody } from 'typeorm-routing-controllers-extensions';
import { TrackIdsNotMatchingError, TrackNotFoundError } from "../errors/TrackErrors";
import { CreateTrack } from '../models/actions/CreateTrack';
import { Track } from '../models/entities/Track';
@@ -78,7 +78,8 @@ export class TrackController {
@ResponseSchema(ResponseEmpty, { statusCode: 204 })
@OnUndefined(204)
@OpenAPI({ description: "Delete a specified track (if it exists)." })
async remove(@EntityFromParam('id') track: Track) {
async remove(@Param("id") id: number) {
let track = await this.trackRepository.findOne({ id: id });
if (!track) { return null; }
await this.trackRepository.delete(track);