Salem, I have tried to return the number of order per hour, so i need to extract the hour in the property createdAt in my order Model that's why i think to use The getHours() method returns the hour for the specified date. My method:
@get('/orders/count-perHour/{date}', {
responses: {
'200': {
description: 'Order model count',
content: { 'application/json': { schema: CountSchema } },
},
},
})
async countPerHour(
@param.path.string('date') date: string): Promise<any> {
let dateStart=new Date(date) ;
dateStart.setSeconds(0);
dateStart.setMinutes(0);
let dateEnd=new Date(date) ;
dateEnd.setSeconds(59);
dateEnd.setMinutes(59);
return await this.orderRepository.count(
{
createdAt: {
lte: dateEnd
,
gte: dateStart
}
}
);
}
the property createdAt in mu model order:
@property({type: 'date',})createdAt?: string;
Error: it return false comparison, for example if i have one order at hour:10 it return 6