I'm having trouble unpacking a calendar structure from sql into golang structs, here is what I have.
type year struct {
year int
months []month
}
type month struct {
month int
days []day
}
type day struct {
day int
hours map[int]bool
}
I'm planning an appointment calendar, each day may have 10:00, 11:00, 12:00, 13:00 etc. and I will read out a maximum of 3 months at a time. I cannot figure out how to unpack the following schema:
CREATE TABLE appointments (
id INT,
year INT,
month INT,
day INT,
hour INT,
teacher INT, (id of teacher)
student INT, (id of student)
amount DECIMAL, (amount charged for the appointment)
booked BOOL, (records availability)
)
The query:
SELECT year, month, day, hour, booked FROM appointments a WHERE a.teacher = ? ORDERY BY day, month, year;