baka9moe / mongoengine_dsl

DSL to MongoEngine Q

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Logo

Release Status

DSL to MongoEngine Q

Features

  • Build your mongoengine query from DSL syntax
  • Convert your data at build time via transform hook

Quickstart

Install

pip install mongoengine_dsl

Use

from mongoengine import Document, StringField
from mongoengine_dsl import Query


class User(Document):
    fullname = StringField()


User(fullname="Tom").save()
User(fullname="Dick").save()
User(fullname="Harry").save()

assert User.objects(
    Query("fullname: Dick")
).first().fullname == "Dick"

assert User.objects(
    Query("fullname: dick", transform={
        "fullname": lambda x: x.title()
    })
).first().fullname == "Dick"

More

Full Documentation: https://stonemoe.github.io/mongoengine_dsl

About

DSL to MongoEngine Q

License:MIT License


Languages

Language:Python 87.2%Language:ANTLR 12.8%