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

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for mgqpy-0.4.1.tar.gz
Algorithm Hash digest
SHA256 3b85f81285baa7dfba354d86e5d336d6d080c80d49594dc3a9d021fc29b13af4
MD5 a94430d3da7b6f98454deb9f450e8680
BLAKE2b-256 052ec823965565f78b2c30fe302d5a32a6f983be507788a8cf419cb00a1c6a62

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mgqpy-0.4.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.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.4.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 552710a22e0a761e8fbbde6755806c0fdac03caaf01aa1f458629ebd50484df1
MD5 2c6df0f1d2e588edd30f3c11771f6f96
BLAKE2b-256 7aa59595e9bf9767a346b63addc85e4d101e88b291810e377f27728860590b0f

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