user type graphql added

This commit is contained in:
2025-11-25 20:16:11 +03:00
parent eedfed1a65
commit 2062aa7a1d
52 changed files with 3111 additions and 45 deletions

View File

@@ -3,6 +3,7 @@ import { randomUUID } from 'crypto';
import { Prop, SchemaFactory } from '@nestjs/mongoose';
import { Field, ID, ObjectType } from '@nestjs/graphql';
import { Base } from '@/models/base.model';
import { Build } from '@/models/build.model';
import { BuildParts } from '@/models/build-parts.model';
import { Person } from '@/models/person.model';
import { Company } from '@/models/company.model';
@@ -11,10 +12,18 @@ import { UserType } from '@/models/user-type.model';
@ObjectType()
export class LivingSpaces extends Base {
@Field(() => ID)
@Prop({ type: Types.ObjectId, ref: Build.name, required: true })
build: Types.ObjectId;
@Field(() => ID)
@Prop({ type: Types.ObjectId, ref: BuildParts.name, required: true })
part: Types.ObjectId;
@Field(() => ID)
@Prop({ type: Types.ObjectId, ref: UserType.name, required: true })
userType: Types.ObjectId;
@Field(() => ID)
@Prop({ type: Types.ObjectId, ref: Company.name, required: true })
company: Types.ObjectId;
@@ -23,10 +32,6 @@ export class LivingSpaces extends Base {
@Prop({ type: Types.ObjectId, ref: Person.name, required: true })
person: Types.ObjectId;
@Field(() => ID)
@Prop({ type: Types.ObjectId, ref: UserType.name, required: true })
userType: Types.ObjectId;
}
export type LivingSpacesDocument = LivingSpaces & Document;
@@ -36,7 +41,5 @@ export function getDynamicLivingSpaceModel(collectionToken: string, conn?: Conne
const connection = conn || defaultConnection;
const collectionName = `LivingSpaces${collectionToken}`;
if (connection.models[collectionName]) { return connection.models[collectionName] as Model<LivingSpacesDocument> }
const schema = SchemaFactory.createForClass(LivingSpaces);
schema.add({ uuid: { type: String, required: false, unique: true, default: () => randomUUID() } });
return connection.model(collectionName, schema, collectionName) as unknown as Model<LivingSpacesDocument>;
throw new Error('No Living Spaces is found')
}

View File

@@ -1,25 +1,35 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
import { ObjectType, Field, ID } from '@nestjs/graphql';
import { Base } from './base.model';
@ObjectType()
@Schema({ timestamps: true })
export class UserType {
@Field()
export class UserType extends Base {
@Field(() => ID)
readonly _id: string
@Field({ nullable: false })
@Prop({ required: true })
type: string;
@Field()
@Field({ nullable: false })
@Prop({ required: true })
token: string;
@Field()
@Field({ nullable: false })
@Prop({ required: true })
typeToken: string;
@Field()
@Field({ nullable: false })
@Prop({ required: true })
description: string;
@Field({ nullable: false })
@Prop({ required: true })
isProperty: boolean;
}
export type UserTypeDocument = UserType & Document;

View File

@@ -3,7 +3,6 @@ import { ObjectType, Field, ID } from '@nestjs/graphql';
import { Document, Types } from 'mongoose';
import { Base } from '@/models/base.model';
import { Person } from '@/models/person.model';
import { UserType } from '@/models/user-type.model';
@ObjectType()
export class CollectionTokenItem {