Commit 0dd313b2 authored by nanahira's avatar nanahira

revert

parent 1feaf24b
......@@ -23,15 +23,14 @@ import { ConsoleLogger } from '@nestjs/common';
import { camelCase } from 'typeorm/util/StringUtils';
import _ from 'lodash';
import { ClassType } from './utility/insert-field';
import { RecursiveKeyOf } from './utility/recursive-key-of';
export type EntityId<T extends { id: any }> = T['id'];
export interface RelationDef<T> {
name: T;
export interface RelationDef {
name: string;
inner?: boolean;
}
export const Inner = <T>(name: T): RelationDef<T> => {
export const Inner = (name: string): RelationDef => {
return { name, inner: true };
};
......@@ -40,7 +39,7 @@ export type ValidCrudEntity<T> = Record<string, any> & {
} & Partial<QueryWise<T> & DeletionWise & EntityHooks & PageSettingsFactory>;
export interface CrudOptions<T extends ValidCrudEntity<T>> {
relations?: (RecursiveKeyOf<T> | RelationDef<RecursiveKeyOf<T>>)[];
relations?: (string | RelationDef)[];
extraGetQuery?: (qb: SelectQueryBuilder<T>) => void;
hardDelete?: boolean;
}
......@@ -53,10 +52,7 @@ export class CrudBase<T extends ValidCrudEntity<T>> {
readonly entityPaginatedReturnMessageDto = PaginatedReturnMessageDto(
this.entityClass,
);
readonly entityRelations: (
| RecursiveKeyOf<T>
| RelationDef<RecursiveKeyOf<T>>
)[];
readonly entityRelations: (string | RelationDef)[];
readonly extraGetQuery: (qb: SelectQueryBuilder<T>) => void;
readonly log = new ConsoleLogger(`${this.entityClass.name}Service`);
......@@ -195,10 +191,7 @@ export class CrudBase<T extends ValidCrudEntity<T>> {
return camelCase(this.entityName);
}
_applyRelationToQuery(
qb: SelectQueryBuilder<T>,
relation: RelationDef<RecursiveKeyOf<T>>,
) {
_applyRelationToQuery(qb: SelectQueryBuilder<T>, relation: RelationDef) {
const { name } = relation;
const relationUnit = name.split('.');
const base =
......@@ -216,7 +209,7 @@ export class CrudBase<T extends ValidCrudEntity<T>> {
_applyRelationsToQuery(qb: SelectQueryBuilder<T>) {
for (const relation of this.entityRelations) {
if (typeof relation === 'string') {
this._applyRelationToQuery(qb, { name: relation as any });
this._applyRelationToQuery(qb, { name: relation });
} else {
this._applyRelationToQuery(qb, relation);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment