Magic filters for MongoDB
Project description
MongoForge
Magic filters for MongoDB
Installation
pip install mongoforge
Basic example
from pymongo import MongoClient
from mongoforge import F
cluster = MongoClient(...)
collection = cluster.db.users
if user := collection.find_one(F._id == 1): # {"_id": 1}
print(user)
else:
collection.insert_one(...)
Available filters
| MongoDB Operator | Python Expression | Example Output |
|---|---|---|
$eq |
F.age == 21 |
{"age": 21} |
$gt |
F.age > 21 |
{"age": {"$gt": 21}} |
$lt |
F.age < 21 |
{"age": {"$lt": 21}} |
$gte |
F.age >= 21 |
{"age": {"$gte": 21}} |
$lte |
F.age <= 21 |
{"age": {"$lte": 21}} |
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
mongoforge-1.1.0.tar.gz
(1.9 kB
view details)
File details
Details for the file mongoforge-1.1.0.tar.gz.
File metadata
- Download URL: mongoforge-1.1.0.tar.gz
- Upload date:
- Size: 1.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee2a96af0bdb1ecdbf93edbc4513daa781607f32801960c49b7c42bf0bd57a8b
|
|
| MD5 |
673c15d849e4a8bf9b3d491a4ad9ad46
|
|
| BLAKE2b-256 |
2848c9c463671d5cffc7809ccd25d5bda6796509bd58d682166f6ad4f173788f
|