Moved categories to the same scope as calendar events
This commit is contained in:
@@ -4,6 +4,7 @@ import type { Category } from "~/models/Category";
|
||||
|
||||
const querySchema = z.object({
|
||||
id: z.number({ coerce: true }).positive().int().optional(),
|
||||
calendarId: z.number({ coerce: true }).positive().int()
|
||||
})
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
@@ -24,5 +25,9 @@ export default defineEventHandler(async (event) => {
|
||||
return output.eq("id", query.id).limit(1).single<Category>()
|
||||
}
|
||||
|
||||
if (query.calendarId) {
|
||||
output.eq("calendar_id", query.calendarId)
|
||||
}
|
||||
|
||||
return output.overrideTypes<Category[]>()
|
||||
})
|
||||
|
||||
@@ -52,6 +52,11 @@ export default defineEventHandler(async (event) => {
|
||||
category:calendar_event_categories!calendar_events_category_fkey (*),
|
||||
secondaryCategories:calendar_event_categories!calendar_event_categories_links (*)
|
||||
),
|
||||
categories:calendar_event_categories (
|
||||
id,
|
||||
name,
|
||||
color
|
||||
),
|
||||
eventNb:calendar_events(count),
|
||||
world:worlds (
|
||||
id,
|
||||
|
||||
Reference in New Issue
Block a user