Options to configure encrypted queries using the range algorithm.
| 269 | |
| 270 | |
| 271 | class RangeOpts: |
| 272 | """Options to configure encrypted queries using the range algorithm.""" |
| 273 | |
| 274 | def __init__( |
| 275 | self, |
| 276 | sparsity: Optional[int] = None, |
| 277 | trim_factor: Optional[int] = None, |
| 278 | min: Optional[Any] = None, |
| 279 | max: Optional[Any] = None, |
| 280 | precision: Optional[int] = None, |
| 281 | ) -> None: |
| 282 | """Options to configure encrypted queries using the range algorithm. |
| 283 | |
| 284 | :param sparsity: An integer. |
| 285 | :param trim_factor: An integer. |
| 286 | :param min: A BSON scalar value corresponding to the type being queried. |
| 287 | :param max: A BSON scalar value corresponding to the type being queried. |
| 288 | :param precision: An integer, may only be set for double or decimal128 types. |
| 289 | |
| 290 | .. versionadded:: 4.4 |
| 291 | """ |
| 292 | self.min = min |
| 293 | self.max = max |
| 294 | self.sparsity = sparsity |
| 295 | self.trim_factor = trim_factor |
| 296 | self.precision = precision |
| 297 | |
| 298 | @property |
| 299 | def document(self) -> dict[str, Any]: |
| 300 | doc = {} |
| 301 | for k, v in [ |
| 302 | ("sparsity", int64.Int64(self.sparsity) if self.sparsity else None), |
| 303 | ("trimFactor", self.trim_factor), |
| 304 | ("precision", self.precision), |
| 305 | ("min", self.min), |
| 306 | ("max", self.max), |
| 307 | ]: |
| 308 | if v is not None: |
| 309 | doc[k] = v |
| 310 | return doc |
| 311 | |
| 312 | |
| 313 | class TextOpts: |
no outgoing calls