Skip to main content

mongo query as a predicate function

Project description

mgqpy

codecov

mongo query as a predicate function

pip install mgqpy
from mgqpy import Query

predicate = Query({"foo.bar": 1})

inputs = [
    {"foo": [{"bar": [1]}]},
    {"foo": {"bar": 1}},
    {"foo": None},
]

filtered = filter(predicate.match, inputs)

assert list(filtered) == [
    {"foo": [{"bar": [1]}]},
    {"foo": {"bar": 1}},
]

Supported operators

Comparison query operators

  • $eq
  • $eq (implicit), e.g. {"foo": None}
  • $ne
  • $gt
  • $gte
  • $lt
  • $lte
  • $in
  • $nin

Logical query operators

  • $and
  • $and (implicit), e.g. {"foo": 1, "bar": "baz"}
  • $or
  • $not
  • $nor

Evaluation query operators

  • $regex
  • $mod

Array query operators

  • $all
  • $elemMatch
  • $size

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mgqpy-0.1.10.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mgqpy-0.1.10-py2.py3-none-any.whl (3.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file mgqpy-0.1.10.tar.gz.

File metadata

  • Download URL: mgqpy-0.1.10.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for mgqpy-0.1.10.tar.gz
Algorithm Hash digest
SHA256 ecf1c0f4c6388ddaf2b02ba7765b3c27d49d39cc6b651fc7bec89091d112dc4e
MD5 901b345aa38c05eb12ff238fc04771c0
BLAKE2b-256 20d00ef079df3563fc7254690129be69fcc2a3aa6a493436abb8a54b7933e886

See more details on using hashes here.

File details

Details for the file mgqpy-0.1.10-py2.py3-none-any.whl.

File metadata

  • Download URL: mgqpy-0.1.10-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for mgqpy-0.1.10-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 55103349da5f2b499c21ac7fd32eccb4ed35301fcafff635f72784bace42c04a
MD5 197767d418b6310d6e885c310f66d849
BLAKE2b-256 39c1c23755fc6d475d836be9505852961a7149be9ca42ae47509a9e09554ddb3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page