Skip to content

Commit

Permalink
Поправит типы в модели предложения
Browse files Browse the repository at this point in the history
  • Loading branch information
AdonaiJehosua committed Sep 14, 2024
1 parent c42e867 commit 8692c03
Showing 1 changed file with 35 additions and 16 deletions.
51 changes: 35 additions & 16 deletions src/shared/modules/offer/offer.entity.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
import {defaultClasses, getModelForClass, modelOptions, prop, Ref, Severity} from '@typegoose/typegoose';
import {defaultClasses, getModelForClass, modelOptions, prop, Ref} from '@typegoose/typegoose';
import {City, Location, OfferGood} from '../../types/index.js';
import {UserEntity} from '../user/index.js';

class LocationGoose {
@prop({type: Number})
public latitude: number;

@prop({type: Number})
public longitude: number;

@prop({type: Number})
public zoom: number;
}

class CityGoose {
@prop({type: String})
public name: string;

@prop({type: LocationGoose})
public location: LocationGoose;
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
export interface OfferEntity extends defaultClasses.Base {
}
Expand All @@ -15,49 +34,49 @@ export interface OfferEntity extends defaultClasses.Base {
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
export class OfferEntity extends defaultClasses.TimeStamps {

@prop({required: true, type: () => String})
@prop({required: true, type: String})
public title: string;

@prop({required: true, type: () => String})
@prop({required: true, type: String})
public type: string;

@prop({required: true, type: () => Number})
@prop({required: true, type: Number})
public price: number;

@prop({required: true, allowMixed: Severity.ALLOW, type: () => Object})
@prop({required: true, type: CityGoose})
public city: City;

@prop({required: true, allowMixed: Severity.ALLOW, type: () => Object})
@prop({required: true, type: LocationGoose})
public location: Location;

@prop({required: true, type: () => Boolean})
@prop({required: true, type: Boolean})
public isFavorite: boolean;

@prop({required: true, type: () => Boolean})
@prop({required: true, type: Boolean})
public isPremium: boolean;

@prop({required: true, type: () => Number})
@prop({required: true, type: Number})
public rating: number;

@prop({required: true, type: () => String})
@prop({required: true, type: String})
public description: string;

@prop({required: true, type: () => Array})
@prop({required: true, type: Array})
public images: string[];

@prop({required: true, type: () => String})
@prop({required: true, type: String})
public previewImage: string;

@prop({required: true, type: () => Array})
@prop({type: Array})
public goods: OfferGood[];

@prop({required: true, ref: () => UserEntity, type: () => String})
@prop({required: true, ref: () => UserEntity, type: String})
public hostId: Ref<UserEntity>;

@prop({required: true, type: () => Number})
@prop({required: true, type: Number})
public bedrooms: number;

@prop({required: true, type: () => Number})
@prop({required: true, type: Number})
public maxAdults: number;
}

Expand Down

0 comments on commit 8692c03

Please sign in to comment.