Compare commits

..

3 Commits

Author SHA1 Message Date
7b948f0380 gets now use the db
ref #4
2020-11-25 20:22:58 +01:00
8c04bd067c Merge branch 'main' of git.odit.services:lfk/backend into main 2020-11-25 19:52:33 +01:00
203d95ee1c Added pirst part of track model db connection
ref #4
2020-11-25 19:43:14 +01:00

View File

@@ -8,17 +8,23 @@ import {
Delete, Delete,
} from "routing-controllers"; } from "routing-controllers";
import { OpenAPI } from "routing-controllers-openapi"; import { OpenAPI } from "routing-controllers-openapi";
import { getConnection, Repository } from "typeorm";
import { Track } from "../models/Track";
@JsonController() @JsonController("/track")
export class TrackController { export class TrackController {
private repo(): Repository<Track> {
return getConnection().getRepository(Track);
}
@Get("/track") @Get("/track")
getAll() { async getAll() {
return "This action returns all users"; return await this.repo().find();
} }
@Get("/track/:id") @Get("/track/:id")
getOne(@Param("id") id: number) { async getOne(@Param("id") id: number) {
return "This action returns user #" + id; return await this.repo().findOne({ id: id });
} }
@Post("/track") @Post("/track")