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.3.0.tar.gz (55.6 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.3.0-py2.py3-none-any.whl (3.8 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for mgqpy-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c91f0d6dc62603fdeee32ba0346887adf2928da9fcd41aebf8b5ca9a8e51cff6
MD5 f8e8e8ca8ae11e5890bf14c076f10846
BLAKE2b-256 8c9641fd0c420e97a91fb94c8eca0ff92387961519f4409cf84ab4ee65d970c6

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for mgqpy-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f05c048cdac09b2558849bf6fbdc017e949217174076a68f5e55228cdcfb926e
MD5 3b31db21f6c6c5b1cc0d902e353bee9c
BLAKE2b-256 942c37c1ae91181ba4f52f5f6c5dc283993e04df83fe0009f28d85c7626b9ae1

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