-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
73 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// since prisma needs nulls to indicate "remove this field" instead of "ignore this field" | ||
// this function translates undefineds into nulls | ||
function nullify<T>(field: T | undefined): T | null { | ||
if (field === undefined) { | ||
return null | ||
} | ||
|
||
return field | ||
} | ||
|
||
// since prisma needs nulls to indicate "remove this field" instead of "ignore this field" | ||
// this function translates undefineds into empty arrays | ||
function emptify<T>(field: T[] | undefined): T[] { | ||
if (field === undefined) { | ||
return [] | ||
} | ||
return field | ||
} | ||
|
||
export { nullify, emptify } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters