Skip to main content

mongo query as a python filter predicate

Project description

mgqpy

mongo query as a python filter predicate

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.8.tar.gz (4.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.1.8-py2.py3-none-any.whl (3.3 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for mgqpy-0.1.8.tar.gz
Algorithm Hash digest
SHA256 645eaae1af36bf4c87e15aabf4b6c65cb092209494f9e9f0f0406ce34f917d1d
MD5 55f5fb59ee1b929d6d62a373c1a29c3a
BLAKE2b-256 6db59196bef1576094aae0b69014d5485b79be9567c70d5c6aae3818e4dee79b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mgqpy-0.1.8-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.3 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.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0fa020ca69d76bb596cb7dcfde628990568fc8c75e0923b9d37bb94143c98644
MD5 2ae192edc65c9afa3767e0d2ef2329c2
BLAKE2b-256 1a5500985426c1603787c53a7102ef39a55d1a119beb704130744e02b4c77c41

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