mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 23:50:08 +00:00
refactor(db): every entity in the snake_case shape; document-sync entities added; one repository per entity
This commit is contained in:
@@ -1,41 +1,43 @@
|
||||
import { Collection, type Opt, type Ref, defineEntity, p } from '@mikro-orm/core';
|
||||
import { BucketListRepository } from '../repositories/BucketList.repository';
|
||||
import { DbTimestampType } from '../types';
|
||||
import { DawarichVisitSuggestions } from './DawarichVisitSuggestions.entity';
|
||||
import { Users } from './Users.entity';
|
||||
import { Collection, defineEntity, p, type Ref, EntityRepository } from '@mikro-orm/core';
|
||||
|
||||
export class BucketList {
|
||||
id?: number | null;
|
||||
id!: number & Opt;
|
||||
user!: Ref<Users>;
|
||||
user_id!: number;
|
||||
name!: string;
|
||||
lat?: unknown | null;
|
||||
lng?: unknown | null;
|
||||
countryCode?: string | null;
|
||||
lat?: number | null;
|
||||
lng?: number | null;
|
||||
country_code?: string | null;
|
||||
notes?: string | null;
|
||||
createdAt?: Date | null;
|
||||
targetDate?: string | null;
|
||||
visitedAt?: string | null;
|
||||
visitedSource?: string | null;
|
||||
dawarichAcceptedBucketListItem = new Collection<DawarichVisitSuggestions>(this);
|
||||
dawarichMatchedBucketListItem = new Collection<DawarichVisitSuggestions>(this);
|
||||
created_at?: string | null;
|
||||
target_date?: string | null;
|
||||
visited_at?: string | null;
|
||||
visited_source?: string | null;
|
||||
dawarich_visit_suggestions_collection = new Collection<DawarichVisitSuggestions>(this);
|
||||
dawarich_visit_suggestions_collection1 = new Collection<DawarichVisitSuggestions>(this);
|
||||
}
|
||||
|
||||
export class BucketListRepository extends EntityRepository<BucketList> {}
|
||||
|
||||
export const BucketListSchema = defineEntity({
|
||||
class: BucketList,
|
||||
repository: () => BucketListRepository,
|
||||
properties: {
|
||||
id: p.integer().primary().autoincrement(),
|
||||
user: () => p.manyToOne(Users).ref().deleteRule('cascade'),
|
||||
id: p.integer().primary(),
|
||||
user: () => p.manyToOne(Users).ref().deleteRule('cascade').hidden(),
|
||||
user_id: p.integer().persist(false),
|
||||
name: p.text(),
|
||||
lat: p.double().nullable(),
|
||||
lng: p.double().nullable(),
|
||||
countryCode: p.text().nullable(),
|
||||
country_code: p.text().nullable(),
|
||||
notes: p.text().nullable(),
|
||||
createdAt: p.datetime().nullable().onCreate(() => new Date()),
|
||||
targetDate: p.text().nullable(),
|
||||
visitedAt: p.text().nullable(),
|
||||
visitedSource: p.text().nullable(),
|
||||
dawarichAcceptedBucketListItem: () => p.oneToMany(DawarichVisitSuggestions).mappedBy('acceptedBucketListItem'),
|
||||
dawarichMatchedBucketListItem: () => p.oneToMany(DawarichVisitSuggestions).mappedBy('matchedBucketListItem'),
|
||||
created_at: p.type(DbTimestampType).nullable().defaultRaw(`CURRENT_TIMESTAMP`),
|
||||
target_date: p.text().nullable().defaultRaw(`NULL`),
|
||||
visited_at: p.text().nullable(),
|
||||
visited_source: p.text().nullable(),
|
||||
dawarich_visit_suggestions_collection: () => p.oneToMany(DawarichVisitSuggestions).mappedBy('acceptedBucketListItem').hidden(),
|
||||
dawarich_visit_suggestions_collection1: () => p.oneToMany(DawarichVisitSuggestions).mappedBy('matchedBucketListItem').hidden(),
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user