Openstatus www.openstatus.dev

fix: empty monitors list (#1401)

authored by

Maximilian Kaske and committed by
GitHub
50ed5fce 3324f78a

+9 -7
+9 -7
packages/api/src/router/page.ts
··· 850 850 .delete(monitorsToPages) 851 851 .where(eq(monitorsToPages.pageId, opts.input.id)); 852 852 853 - await tx.insert(monitorsToPages).values( 854 - opts.input.monitors.map((m) => ({ 855 - pageId: opts.input.id, 856 - monitorId: m.id, 857 - order: m.order, 858 - })), 859 - ); 853 + if (opts.input.monitors.length > 0) { 854 + await tx.insert(monitorsToPages).values( 855 + opts.input.monitors.map((m) => ({ 856 + pageId: opts.input.id, 857 + monitorId: m.id, 858 + order: m.order, 859 + })), 860 + ); 861 + } 860 862 }); 861 863 }), 862 864 });