본문으로 건너뛰기

함수: extractSimpleComparisons()

function extractSimpleComparisons(expr): SimpleComparison[];

정의 위치: packages/db/src/query/expression-helpers.ts:327

WHERE 표현식에서 모든 단순 비교를 추출합니다. 기본 필터만 지원하는 단순 API에 유용합니다.

참고: 단순한 AND 조건과 NOT으로 래핑된 비교에서만 작동합니다. OR 또는 복잡하게 중첩된 표현식과 같이 지원되지 않는 연산을 만나면 오류를 발생시킵니다.

NOT 연산자는 연산자 이름을 접두사로 붙여 평탄화됩니다(예: not(eq(...))not_eq이 됩니다).

매개변수

expr

구문 분석할 WHERE 표현식입니다

BasicExpression<boolean> | null | undefined

반환값

SimpleComparison[]

단순 비교의 배열입니다

발생하는 오류

표현식에 OR 또는 지원되지 않는 다른 연산이 포함된 경우 오류가 발생합니다

예제

const comparisons = extractSimpleComparisons(where)
// Returns: [
// { field: ['category'], operator: 'eq', value: 'electronics' },
// { field: ['price'], operator: 'lt', value: 100 },
// { field: ['email'], operator: 'isNull' }, // No value for null checks
// { field: ['status'], operator: 'not_eq', value: 'archived' }
// ]