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.6.tar.gz (4.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.1.6-py2.py3-none-any.whl (3.0 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for mgqpy-0.1.6.tar.gz
Algorithm Hash digest
SHA256 c58222bd703f65ff09ba2453a7cdd1a7b80d75ecc168a6757a4d624a41551f8b
MD5 fb76f8113badf2f105e71bed6e7add08
BLAKE2b-256 d80fe05bc0e14ba99d7fec774b06aadc4c2a443e32a3b8471677987c0038bc96

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mgqpy-0.1.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.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.1.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c8cdb4171cc621b169bfb1ec4219fe4d2b3614c1aafbf10401fc5cb41ad95137
MD5 00bac51060457c15c536dc8217a927ae
BLAKE2b-256 feca0a921ed2d61cc47a5907227f97b2ef2e9acca8756e7b2f50b953b9d9623a

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