Skip to main content

mongo query as a python filter predicate

Project description

mgqpy

mongo query as a python filter predicate

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

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for mgqpy-0.1.7.tar.gz
Algorithm Hash digest
SHA256 300c7730d35a8eaf7b06804f376054bc6d7c275d1c3251182fbe10efb4797d4b
MD5 ba25559ec58f12f4c4ac02295a5f2af0
BLAKE2b-256 964922e3f102dcba0d2f903eb0c45e90f732c35ea83537900a255290fd60c2d0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mgqpy-0.1.7-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.1 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.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3e2e7603548c061dea9925098a77b7e19fd9dfc241cdf963514139017c921731
MD5 a4a5328bb432239da1015b7e5bc8027b
BLAKE2b-256 2e7055325dc5d42333a6de32a7dd453cd386041d9f7f7bc62d3b3a0833893198

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