mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 08:30:05 +00:00
26 lines
950 B
TypeScript
26 lines
950 B
TypeScript
import { type Ref, defineEntity, p, EntityRepository } from '@mikro-orm/core';
|
|
import { CollectionPlaces } from './CollectionPlaces.js';
|
|
import { Users } from './Users.js';
|
|
|
|
export class CollectionPlaceRatings {
|
|
id?: number | null;
|
|
collectionPlace!: Ref<CollectionPlaces>;
|
|
user!: Ref<Users>;
|
|
rating!: number;
|
|
createdAt?: Date | null;
|
|
}
|
|
|
|
export class CollectionPlaceRatingsRepository extends EntityRepository<CollectionPlaceRatings> {}
|
|
|
|
export const CollectionPlaceRatingsSchema = defineEntity({
|
|
class: CollectionPlaceRatings,
|
|
repository: () => CollectionPlaceRatingsRepository,
|
|
properties: {
|
|
id: p.integer().primary().autoincrement(),
|
|
collectionPlace: () => p.manyToOne(CollectionPlaces).ref().deleteRule('cascade').index('idx_collection_place_ratings_place'),
|
|
user: () => p.manyToOne(Users).ref().deleteRule('cascade'),
|
|
rating: p.integer(),
|
|
createdAt: p.datetime().nullable().onCreate(() => new Date()),
|
|
},
|
|
});
|