Add basic local api wrapper

This commit is contained in:
2022-07-22 06:07:24 +01:00
parent befd8dc9cd
commit 71aabb3ca6
2 changed files with 42 additions and 3 deletions

View File

@@ -0,0 +1,25 @@
import { PaginatedDocs } from 'payload/dist/mongoose/types';
import { Payload } from 'payload';
export default function findEventsOnDay(payload: Payload, day: string): Promise<PaginatedDocs> {
const startOfDate = new Date(day).setUTCHours(0, 0, 0, 0);
const endOfDate = new Date(day).setUTCHours(23, 59, 59, 999);
return payload.find({
collection: 'events',
where: {
and: [
{
startTime: {
greater_than_equal: startOfDate
}
},
{
startTime: {
less_than_equal: endOfDate
}
}
]
}
});
}