gets now use the db

ref #4
This commit is contained in:
Nicolai Ort 2020-11-25 20:22:58 +01:00
parent 8c04bd067c
commit 7b948f0380

View File

@ -13,20 +13,18 @@ import { Track } from "../models/Track";
@JsonController("/track")
export class TrackController {
private repo: Repository<Track>;
public async TrackController() {
const trackManager = await getConnection().getRepository(Track);
private repo(): Repository<Track> {
return getConnection().getRepository(Track);
}
@Get("/track")
async getAll() {
return await this.repo.count();
return await this.repo().find();
}
@Get("/track/:id")
getOne(@Param("id") id: number) {
return "This action returns user #" + id;
async getOne(@Param("id") id: number) {
return await this.repo().findOne({ id: id });
}
@Post("/track")