mongo query as a predicate function
Project description
mgqpy
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
Release history Release notifications | RSS feed
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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62c154397dae95251acebafd74d1ac6825066e13ec034711ad5959ea2c21caa5
|
|
| MD5 |
6afb29b23475aaeb22861ec72fdd5206
|
|
| BLAKE2b-256 |
6c92a59be6992b0c206444af8b37e615aed597dd176f1e6bc8f3552bd7a81e7a
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a4fa7549675e70df6118b81672ac27adf20a84051a36ba4ad192b8f6bf5c96a
|
|
| MD5 |
43cead303057d7039a71c027afa55f76
|
|
| BLAKE2b-256 |
a5da2c58591155fc11736431f8f8208262960e5eecd0a02a20e3b3ecaf08776a
|