mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-28 21:49:40 +02:00
12 lines
466 B
TypeScript
12 lines
466 B
TypeScript
import { defineQuery } from "@rocicorp/zero";
|
|
import { z } from "zod";
|
|
import { zql } from "../schema/index";
|
|
|
|
export const notificationQueries = {
|
|
byUser: defineQuery(z.object({ userId: z.string() }), ({ args: { userId }, ctx }) => {
|
|
if (!ctx?.userId || userId !== ctx.userId) {
|
|
return zql.notifications.where("userId", "__none__").orderBy("createdAt", "desc");
|
|
}
|
|
return zql.notifications.where("userId", ctx.userId).orderBy("createdAt", "desc");
|
|
}),
|
|
};
|