Refactored and improved seeds (#8695)
- Added a new Seeder service to help with custom object seeds - Added RichTextFieldInput to edit a rich text field directly on the table, but deactivated it for now.
This commit is contained in:
@ -3,17 +3,22 @@ import {
|
||||
Injectable,
|
||||
UnauthorizedException,
|
||||
} from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import {
|
||||
BeforeDeleteOneHook,
|
||||
DeleteOneInputType,
|
||||
} from '@ptc-org/nestjs-query-graphql';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
import { RelationMetadataService } from 'src/engine/metadata-modules/relation-metadata/relation-metadata.service';
|
||||
import { RelationMetadataEntity } from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
|
||||
|
||||
@Injectable()
|
||||
export class BeforeDeleteOneRelation implements BeforeDeleteOneHook {
|
||||
constructor(readonly relationMetadataService: RelationMetadataService) {}
|
||||
constructor(
|
||||
@InjectRepository(RelationMetadataEntity, 'metadata')
|
||||
private readonly relationMetadataRepository: Repository<RelationMetadataEntity>,
|
||||
) {}
|
||||
|
||||
async run(
|
||||
instance: DeleteOneInputType,
|
||||
@ -25,12 +30,13 @@ export class BeforeDeleteOneRelation implements BeforeDeleteOneHook {
|
||||
throw new UnauthorizedException();
|
||||
}
|
||||
|
||||
const relationMetadata =
|
||||
await this.relationMetadataService.findOneWithinWorkspace(workspaceId, {
|
||||
where: {
|
||||
id: instance.id.toString(),
|
||||
},
|
||||
});
|
||||
const relationMetadata = await this.relationMetadataRepository.findOne({
|
||||
where: {
|
||||
workspaceId,
|
||||
id: instance.id.toString(),
|
||||
},
|
||||
relations: ['fromFieldMetafata', 'toFieldMetadata'],
|
||||
});
|
||||
|
||||
if (!relationMetadata) {
|
||||
throw new BadRequestException('Relation does not exist');
|
||||
|
||||
Reference in New Issue
Block a user