Skip to content

bigdata-pw/mongo-helpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

mongo-helpers

helper functions for pymongo

Usage

uri = ""
client = MongoClient(uri)
db = client.example
example = db["example"]

example.find_one(
    query_and([
        query_gt("count", 0),
        query_lt("count", 10),
    ])
)

example.count_documents(query_exists("test"))

duplicates = find_duplicates(example, "test")

Equivalent to

uri = ""
client = MongoClient(uri)
db = client.example
example = db["example"]

example.find_one(
    {"$and": [
        {"count": {"$gt": 0}},
        {"count": {"$lt": 10}}
    ]}
)

example.count_documents({"test": {"$exists": True}})

pipeline = [
    {"$group": {"_id": "$test", "count": {"$count": {
    {"$match": {"count": {"$gt": 1}}},
]
duplicates = list(example.aggregate(pipeline))

Why

It's just easier to use

Releases

No releases published

Packages

No packages published

Languages