From b4f07c2137779a70bb0c7512bfb037b916b80779 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Tue, 10 Sep 2024 15:42:56 +0700 Subject: [PATCH] chore: add helper function --- src/utils/relation.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/utils/relation.ts diff --git a/src/utils/relation.ts b/src/utils/relation.ts new file mode 100644 index 0000000..1007bc0 --- /dev/null +++ b/src/utils/relation.ts @@ -0,0 +1,9 @@ +export function connectOrNot(id?: string | null) { + return { connect: id ? { id } : undefined }; +} +export function connectOrDisconnect(id?: string | null) { + return { + connect: id ? { id } : undefined, + disconnect: id === null || undefined, + }; +}