mirror of
https://github.com/samsonjs/immich.git
synced 2026-03-27 09:35:51 +00:00
15 lines
441 B
TypeScript
15 lines
441 B
TypeScript
import { Between, LessThanOrEqual, MoreThanOrEqual } from 'typeorm';
|
|
|
|
/**
|
|
* Allows optional values unlike the regular Between and uses MoreThanOrEqual
|
|
* or LessThanOrEqual when only one parameter is specified.
|
|
*/
|
|
export default function OptionalBetween<T>(from?: T, to?: T) {
|
|
if (from && to) {
|
|
return Between(from, to);
|
|
} else if (from) {
|
|
return MoreThanOrEqual(from);
|
|
} else if (to) {
|
|
return LessThanOrEqual(to);
|
|
}
|
|
}
|