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

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for mgqpy-0.4.0.tar.gz
Algorithm Hash digest
SHA256 6a610bff7a69f58e0bd1a40d18d3ce556c9a7b7dd67963a982e26c0b5a2ca188
MD5 371780fa24196c7c5cf3277b20cc162f
BLAKE2b-256 96058173f617edd0979dbeace4a3afae4815299ec56195c218ff16256ca11d8c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mgqpy-0.4.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.2 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.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 11ab81010f3ccd98990f27c8aafaf74638fa24e4227bec04ae71684ec59e0fd2
MD5 c3f709ca274f9c1e30e5fa70e619175d
BLAKE2b-256 56fdc66cbd457b065d11252feeebffc82d07d6471a33ff9119df20a481920e8c

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