feat: soft delete (#6576)
Implement soft delete on standards and custom objects. This is a temporary solution, when we drop `pg_graphql` we should rely on the `softDelete` functions of TypeORM. --------- Co-authored-by: Félix Malfait <felix.malfait@gmail.com> Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
@ -22,12 +22,18 @@ type EntitySchemaColumnMap = {
|
||||
export class EntitySchemaColumnFactory {
|
||||
create(
|
||||
fieldMetadataCollection: FieldMetadataEntity[],
|
||||
softDelete: boolean,
|
||||
): EntitySchemaColumnMap {
|
||||
let entitySchemaColumnMap: EntitySchemaColumnMap = {};
|
||||
|
||||
for (const fieldMetadata of fieldMetadataCollection) {
|
||||
const key = fieldMetadata.name;
|
||||
|
||||
// Skip deletedAt column if soft delete is not enabled
|
||||
if (!softDelete && key === 'deletedAt') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isRelationFieldMetadataType(fieldMetadata.type)) {
|
||||
const relationMetadata =
|
||||
fieldMetadata.fromRelationMetadata ??
|
||||
|
||||
@ -21,6 +21,7 @@ export class EntitySchemaFactory {
|
||||
): Promise<EntitySchema> {
|
||||
const columns = this.entitySchemaColumnFactory.create(
|
||||
objectMetadata.fields,
|
||||
objectMetadata.isSoftDeletable ?? false,
|
||||
);
|
||||
|
||||
const relations = await this.entitySchemaRelationFactory.create(
|
||||
|
||||
Reference in New Issue
Block a user