Error: Cannot Read Properties of Undefined (Reading 'databaseName') in NestJS Paginate with TypeORM Relations #1021
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working on a NestJS project where I'm using nestjs-paginate with TypeORM. I have a Customer entity that has PhoneNumber and Dealer as related entities, and I’m trying to paginate Customer records along with these relations.
Here's my Customer entity:
`@Entity()
export class Customer extends BaseEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
}`
In the CustomerService, I have the following findAll function for pagination:
async findAll(query: PaginateQuery): Promise<Paginated<Customer>> { return paginate(query, this.customerRepository, { sortableColumns: ['id', 'name', 'tc_no', 'email'], relations: ['dealer', 'phoneNumber'], nullSort: 'last', defaultSortBy: [['id', 'DESC']], searchableColumns: ['name', 'tc_no', 'email', 'address'], select: [ 'id', 'name', 'tc_no', 'phoneNumber', 'address', 'email', 'dealer', 'created', 'updated', 'deleted' ], filterableColumns: { name: [FilterOperator.EQ, FilterSuffix.NOT], email: [FilterOperator.EQ], tc_no: [FilterOperator.EQ], deleted: [FilterOperator.EQ], }, }); }When running this code, I'm encountering the following error:
[Nest] ERROR [ExceptionsHandler] Cannot read properties of undefined (reading 'databaseName') TypeError: Cannot read properties of undefined (reading 'databaseName') at /typeorm/query-builder/SelectQueryBuilder.ts:3685:41
Beta Was this translation helpful? Give feedback.
All reactions