updated living space

This commit is contained in:
2025-11-26 16:10:15 +03:00
parent 2062aa7a1d
commit 3aebb79d36
38 changed files with 709 additions and 688 deletions

View File

@@ -75,6 +75,23 @@ export class Base {
}
@ObjectType({ isAbstract: true })
export class CreatedBase {
@Field()
@Prop({ default: () => new Date(Date.now()), required: false })
createdAt?: Date;
@Field()
@Prop({ default: () => new Date(Date.now()), required: false })
updatedAt?: Date;
}
@ObjectType({ isAbstract: true })
export class ExpiryBase {

View File

@@ -1,7 +1,7 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
import { ObjectType, Field, ID, Int } from '@nestjs/graphql';
import { Base } from '@/models/base.model';
import { Base, CreatedBase } from '@/models/base.model';
import { Person } from '@/models/person.model';
import { Company } from '@/models/company.model';
import { BuildTypes } from './build-types.model';
@@ -119,7 +119,7 @@ export class BuildInfo {
@ObjectType()
@Schema({ timestamps: true })
export class Build {
export class Build extends CreatedBase {
@Field()
readonly _id: string;

View File

@@ -24,11 +24,11 @@ export class UserTypesService {
return this.userTypesModel.findById(id, projection, { lean: false }).populate({ path: 'buildSites', select: projection?.buildSites }).exec();
}
async create(input: CreateUserTypesInput): Promise<UserTypeDocument> { const buildSite = new this.userTypesModel(input); return buildSite.save() }
async create(input: CreateUserTypesInput): Promise<UserTypeDocument> { const userType = new this.userTypesModel(input); return userType.save() }
async update(uuid: string, input: UpdateUserTypeInput): Promise<UserTypeDocument> { const buildSite = await this.userTypesModel.findOne({ uuid }); if (!buildSite) { throw new Error('BuildSite not found') }; buildSite.set(input); return buildSite.save() }
async update(uuid: string, input: UpdateUserTypeInput): Promise<UserTypeDocument> { const userType = await this.userTypesModel.findOne({ uuid }); if (!userType) { throw new Error('User Type not found') }; userType.set(input); return userType.save() }
async delete(uuid: string): Promise<boolean> { const buildSite = await this.userTypesModel.deleteMany({ uuid }); return buildSite.deletedCount > 0 }
async delete(uuid: string): Promise<boolean> { const userType = await this.userTypesModel.deleteMany({ uuid }); return userType.deletedCount > 0 }
buildProjection(fields: Record<string, any>): any {
const projection: any = {};