I have NestJS application I have to get the query from the URL. Problem is that my creationDate is an object and I can't get it as the nested object via @Query.
Here is example of the route:
xxx/yyy/orders?key1=value&key2=value&key3=value&createdAt[lte]=2021-07-01&createdAt[gte]=2011-03-30&orderBy=desc&limit=500
I am trying to get createdAt[lte] and createdAt[gte] as the nested object
export interface QueryI {
key1: string;
key2: string;
key3: string;
key4: string;
createdAt: {
lte: string,
gte: string,
}
orderBy: 'desc' | 'asc';
limit: number;
}
Here is my controller:
@Get('route')
getAll(
@Query() query: QueryI): Promise<void> {
return this.myService.findAll(query);
}
but this gives me following result
{
key1: 'value',
key2: 'value',
key3: 'value',
key4: 'value',
'createdAt[lte]': 'some date',
'createdAt[gte]': 'some date',
orderBy: 'desc',
limit: '500'
}
I have tried JSON.stringify and consulted similar questions on SOW but no luck.
Thank you