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

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for mgqpy-0.3.1.tar.gz
Algorithm Hash digest
SHA256 62c154397dae95251acebafd74d1ac6825066e13ec034711ad5959ea2c21caa5
MD5 6afb29b23475aaeb22861ec72fdd5206
BLAKE2b-256 6c92a59be6992b0c206444af8b37e615aed597dd176f1e6bc8f3552bd7a81e7a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mgqpy-0.3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.0 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.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4a4fa7549675e70df6118b81672ac27adf20a84051a36ba4ad192b8f6bf5c96a
MD5 43cead303057d7039a71c027afa55f76
BLAKE2b-256 a5da2c58591155fc11736431f8f8208262960e5eecd0a02a20e3b3ecaf08776a

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