How to cycle through appointment times to find a free slot?

Viewed 47

I am designing a database for a dentist and I am creating some queries that help with daily operations. The daily appointment times for the dentist can only be 09:30, 11:00, 14:00 or 16:00. If one of these slots is free then an appointment can be made.

Here is the query in SQL:

DECLARE @apptTime TIME

SET @apptTime = '09:30.00'

--if > 0 then the slot is taken

SELECT IIF(COUNT(*) > 0, “Slot Taken”, “Slot Available”) AS Slot
FROM Appointment
WHERE @apptTime BETWEEN StartTime AND EndTime 
    AND A.Appointment_Date < DATEADD(DAY,2,GETDATE())

I'm not sure how to use declare statements in mongodb.

I know I'm supposed to make an attempt at this but I really don't know where to start. I imagine $cond would be used?

0 Answers
Related