Add Relation Metadata (#2388)
* Add Relation Metadata * remove logs * fix migrations * add one-to-many relation inside entities * fix relation * use enum for tenant migration column action type
This commit is contained in:
@ -20,6 +20,7 @@ import {
|
||||
import { ObjectMetadataInterface } from 'src/tenant/schema-builder/interfaces/object-metadata.interface';
|
||||
|
||||
import { FieldMetadata } from 'src/metadata/field-metadata/field-metadata.entity';
|
||||
import { RelationMetadata } from 'src/metadata/relation-metadata/relation-metadata.entity';
|
||||
|
||||
import { BeforeCreateOneObject } from './hooks/before-create-one-object.hook';
|
||||
|
||||
@ -95,6 +96,12 @@ export class ObjectMetadata implements ObjectMetadataInterface {
|
||||
})
|
||||
fields: FieldMetadata[];
|
||||
|
||||
@OneToMany(() => RelationMetadata, (relation) => relation.fromObjectMetadata)
|
||||
fromRelations: RelationMetadata[];
|
||||
|
||||
@OneToMany(() => RelationMetadata, (relation) => relation.toObjectMetadata)
|
||||
toRelations: RelationMetadata[];
|
||||
|
||||
@Field()
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt: Date;
|
||||
|
||||
@ -5,7 +5,7 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import { Repository } from 'typeorm';
|
||||
import { Equal, In, Repository } from 'typeorm';
|
||||
import { TypeOrmQueryService } from '@ptc-org/nestjs-query-typeorm';
|
||||
import { DeleteOneOptions } from '@ptc-org/nestjs-query-core';
|
||||
|
||||
@ -93,6 +93,16 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadata> {
|
||||
});
|
||||
}
|
||||
|
||||
public async findManyWithinWorkspace(
|
||||
objectMetadataIds: string[],
|
||||
workspaceId: string,
|
||||
) {
|
||||
return this.objectMetadataRepository.findBy({
|
||||
id: In(objectMetadataIds),
|
||||
workspaceId: Equal(workspaceId),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Create all standard objects and fields metadata for a given workspace
|
||||
|
||||
Reference in New Issue
Block a user