Skip to content

Is there a simpler way to filter for a single document, using more than one parameter? #527

Answered by petersamokhin
NetOpWibby asked this question in Q&A
Discussion options

You must be logged in to vote

A dirty workaround but will help:

export function combineOp(
  operator: string,
  ...inputs: $expr_Operator<any, any>[]
): $expr_Operator<any, any> | undefined {
  if (inputs.length === 0) {
    return undefined
  }

  if (inputs.length === 1) {
    return inputs[0]
  }

  return e.op(
    inputs[0] as $expr_Operator<any, any>,
    operator as never,
    combineOp(operator, ...inputs.slice(1)) as $expr_Operator<any, any>,
  )
}

export function andOp(
  ...inputs: $expr_Operator<any, any>[]
): $expr_Operator<any, any> | undefined {
  return combineOp('and', ...inputs)
}

export function orOp(
  ...inputs: $expr_Operator<any, any>[]
): $expr_Operator<any, any> | undefined {
  return combi…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
8 replies
@petersamokhin
Comment options

@NetOpWibby
Comment options

@NetOpWibby
Comment options

@NetOpWibby
Comment options

@NetOpWibby
Comment options

Answer selected by NetOpWibby
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants