feat: add hazards
Some checks failed
TrafficCue Server CI / check (push) Failing after 27s
TrafficCue Server CD / build (push) Successful in 1m48s

This commit is contained in:
2025-09-18 11:48:37 +02:00
parent 7b8210ab7e
commit fb8e3ae8d5
4 changed files with 119 additions and 0 deletions

32
src/entities/Hazard.ts Normal file
View File

@@ -0,0 +1,32 @@
import { BaseEntity, Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
import type { User } from "./User";
@Entity()
export class Hazard extends BaseEntity {
@PrimaryGeneratedColumn("uuid")
id: string;
@Column({
type: "float"
})
latitude: number;
@Column({
type: "float"
})
longitude: number;
@Column()
type: string;
@Column()
votes: number;
@Column({
default: () => "NOW()",
})
created_at: Date;
@ManyToOne("User", (u: User) => u.hazards)
user: User;
}

View File

@@ -7,6 +7,7 @@ import {
} from "typeorm";
import { type Review } from "./Review";
import { type Saved } from "./Saved";
import type { Hazard } from "./Hazard";
@Entity()
export class User extends BaseEntity {
@@ -22,6 +23,9 @@ export class User extends BaseEntity {
@OneToMany("Saved", (s: Saved) => s.user)
saved: Saved[];
@OneToMany("Hazards", (h: Hazard) => h.user)
hazards: Hazard[];
@Column({
default: () => "NOW()",
})