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
  • $regex (implicit), e.g. {"foo": re.compile('^bar')}
  • $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.5.0.tar.gz (56.3 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.5.0-py2.py3-none-any.whl (4.4 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for mgqpy-0.5.0.tar.gz
Algorithm Hash digest
SHA256 04434a560ec0377f628cfd9093559e739f5f4e30c01ac49c85c882489558965e
MD5 c5d0b8c24bda131d8831afebece7b0d1
BLAKE2b-256 1a690f790ef09224e0e47f3c2649a4627ccf40105aa2fc4810de3fa2e1ec67c7

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for mgqpy-0.5.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ff23b1423ffa49019e1b5cc817fcf6c45163d6c3ec3b5227a4ed0c00a2cb1c9b
MD5 9c65f168bfe708485e2c546dd2270b58
BLAKE2b-256 8341d252385e8c830d5e3c80898554d6476c01d8b5e35a16f964a45709674d45

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