updated build add update delete
This commit is contained in:
@@ -35,19 +35,18 @@ export class BuildService {
|
||||
}
|
||||
|
||||
async create(input: CreateBuildInput): Promise<BuildDocument> {
|
||||
const getObjectIDofToken = await this.buildTypeModel.findOne({ token: input.buildType });
|
||||
const getObjectIDofToken = await this.buildTypeModel.findOne({ _id: new Types.ObjectId(input.buildType) });
|
||||
const build = new this.buildModel(input);
|
||||
if (!getObjectIDofToken?._id) { throw new Error('Build type not found') }
|
||||
const idOfBuildTypes = new Types.ObjectId(getObjectIDofToken._id)
|
||||
build.set({ buildType: idOfBuildTypes });
|
||||
await build.populate('buildType')
|
||||
build.set({ buildType: idOfBuildTypes }); await build.populate('buildType');
|
||||
return build.save()
|
||||
}
|
||||
|
||||
async update(uuid: string, input: UpdateBuildInput): Promise<BuildDocument> {
|
||||
let idOfBuildTypes: Types.ObjectId | null = null;
|
||||
if (input.buildType) {
|
||||
const buildTypeDoc = await this.buildTypeModel.findOne({ token: input.buildType });
|
||||
const buildTypeDoc = await this.buildTypeModel.findOne({ _id: new Types.ObjectId(input.buildType) });
|
||||
if (!buildTypeDoc?._id) { throw new Error('Build type not found') }; idOfBuildTypes = new Types.ObjectId(buildTypeDoc._id);
|
||||
}
|
||||
const build = await this.buildModel.findById(new Types.ObjectId(uuid));
|
||||
|
||||
@@ -92,7 +92,7 @@ export class UpdateBuildInfoInput {
|
||||
garageCount?: number;
|
||||
|
||||
@Field({ nullable: true })
|
||||
managementRoomId?: number;
|
||||
managementRoomId?: string;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -128,10 +128,6 @@ export class Build extends CreatedBase {
|
||||
@Prop({ type: Types.ObjectId, ref: BuildTypes.name, required: true })
|
||||
buildType: Types.ObjectId;
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
@Prop({ required: true })
|
||||
collectionToken: string;
|
||||
|
||||
@Field(() => BuildInfo, { nullable: true })
|
||||
@Prop({ type: BuildInfo, required: true })
|
||||
info: BuildInfo;
|
||||
|
||||
Reference in New Issue
Block a user