UNPKG

@elsikora/nestjs-crud-automator

Version:

A library for automating the creation of CRUD operations in NestJS.

31 lines (29 loc) 1.1 kB
/** * Merges two WHERE expressions by building a Cartesian product of OR branches. * @template E - Entity type * @param {TApiAuthorizationScopeWhere<E>} baseWhere - Existing filter. * @param {TApiAuthorizationScopeWhere<E>} scopedWhere - Additional scope filter. * @returns {TApiAuthorizationScopeWhere<E>} Combined filter. */ function AuthorizationScopeMergeWhere(baseWhere, scopedWhere) { if (!baseWhere) { return scopedWhere; } if (!scopedWhere) { return baseWhere; } const baseVariants = Array.isArray(baseWhere) ? baseWhere : [baseWhere]; const scopedVariants = Array.isArray(scopedWhere) ? scopedWhere : [scopedWhere]; const mergedVariants = []; for (const baseVariant of baseVariants) { for (const scopedVariant of scopedVariants) { mergedVariants.push({ ...baseVariant, ...scopedVariant, }); } } return mergedVariants.length === 1 ? mergedVariants[0] : mergedVariants; } export { AuthorizationScopeMergeWhere }; //# sourceMappingURL=where.utility.js.map