All Projects → MongoEngine → Mongoengine

MongoEngine / Mongoengine

Licence: mit
MongoEngine is a Python Object-Document Mapper for working with MongoDB. Documentation is available at https://mongoengine-odm.readthedocs.io - there is currently a tutorial, a user guide, and an API reference.

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to Mongoengine

Odmantic
Async ODM (Object Document Mapper) for MongoDB based on python type hints
Stars: ✭ 240 (-93.39%)
Mutual labels:  orm, mongo, odm, mongodb
Denodb
MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno
Stars: ✭ 498 (-86.29%)
Mutual labels:  orm, mongo, mongodb
Wither
An ODM for MongoDB built on the official MongoDB Rust driver.
Stars: ✭ 174 (-95.21%)
Mutual labels:  orm, odm, mongodb
Php Mongo
MongoDB ODM. Part of @PHPMongoKit
Stars: ✭ 228 (-93.72%)
Mutual labels:  mongo, odm, mongodb
Laravel Mongodb
A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)
Stars: ✭ 5,860 (+61.34%)
Mutual labels:  orm, mongo, mongodb
Mongo Thingy
🍃 The most idiomatic and friendly-yet-powerful way to use MongoDB with Python
Stars: ✭ 49 (-98.65%)
Mutual labels:  orm, odm, mongodb
Mgm
Mongo Go Models (mgm) is a fast and simple MongoDB ODM for Go (based on official Mongo Go Driver)
Stars: ✭ 265 (-92.7%)
Mutual labels:  mongo, odm, mongodb
Prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite & MongoDB (Preview)
Stars: ✭ 18,168 (+400.22%)
Mutual labels:  orm, mongo, mongodb-orm
Qxorm
QxOrm library - C++ Qt ORM (Object Relational Mapping) and ODM (Object Document Mapper) library - Official repository
Stars: ✭ 176 (-95.15%)
Mutual labels:  orm, odm, mongodb
pymongo inmemory
A mongo mocking library with an ephemeral MongoDB running in memory.
Stars: ✭ 25 (-99.31%)
Mutual labels:  mongo, pymongo
derivejs
DeriveJS is a reactive ODM - Object Document Mapper - framework, a "wrapper" around a database, that removes all the hassle of data-persistence by handling it transparently in the background, in a DRY manner.
Stars: ✭ 54 (-98.51%)
Mutual labels:  mongo, odm
moongoon
An object-document mapper for MongoDB. 🌙
Stars: ✭ 41 (-98.87%)
Mutual labels:  mongo, odm
Mikro Orm
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite databases.
Stars: ✭ 3,874 (+6.66%)
Mutual labels:  orm, mongodb
php-mongo-migrator
Migrations of MongoDB. Part of @PHPMongoKit
Stars: ✭ 29 (-99.2%)
Mutual labels:  mongo, odm
Db
Data access layer for PostgreSQL, CockroachDB, MySQL, SQLite and MongoDB with ORM-like features.
Stars: ✭ 2,832 (-22.03%)
Mutual labels:  orm, mongodb
mongu
🌱 Yet another Python Object-Document Mapper on top of PyMongo. It's lightweight, intuitive to use and easy to understand.
Stars: ✭ 15 (-99.59%)
Mutual labels:  pymongo, odm
DoctrineMongoODMModule
Laminas Module for Doctrine MongoDB ODM
Stars: ✭ 83 (-97.71%)
Mutual labels:  mongo, odm
Grails Data Mapping
GORM - Groovy Object Mapping
Stars: ✭ 194 (-94.66%)
Mutual labels:  orm, mongodb
Ming
MongoDB ODM (Object Document Mapper) with Unit of Works, IdentityMap, Relations and Mongo-In-Memory implementation
Stars: ✭ 19 (-99.48%)
Mutual labels:  pymongo, odm
doctrine-json-odm
JSON Object-Document Mapping bundle for Symfony and Doctrine
Stars: ✭ 15 (-99.59%)
Mutual labels:  orm, odm

MongoEngine

Info:MongoEngine is an ORM-like layer on top of PyMongo.
Repository:https://github.com/MongoEngine/mongoengine
Author: Harry Marr (http://github.com/hmarr)
Maintainer:Stefan Wójcik (http://github.com/wojcikstefan)
https://travis-ci.org/MongoEngine/mongoengine.svg?branch=master https://coveralls.io/repos/github/MongoEngine/mongoengine/badge.svg?branch=master https://pepy.tech/badge/mongoengine/month

About

MongoEngine is a Python Object-Document Mapper for working with MongoDB. Documentation is available at https://mongoengine-odm.readthedocs.io - there is currently a tutorial, a user guide, and an API reference.

Supported MongoDB Versions

MongoEngine is currently tested against MongoDB v3.6, v4.0, v4.2 and v4.4. Future versions should be supported as well, but aren't actively tested at the moment. Make sure to open an issue or submit a pull request if you experience any problems with a more recent MongoDB versions.

Installation

We recommend the use of virtualenv and of pip. You can then use python -m pip install -U mongoengine. You may also have setuptools and thus you can use easy_install -U mongoengine. Another option is pipenv. You can then use pipenv install mongoengine to both create the virtual environment and install the package. Otherwise, you can download the source from GitHub and run python setup.py install.

The support for Python2 was dropped with MongoEngine 0.20.0

Dependencies

All of the dependencies can easily be installed via python -m pip. At the very least, you'll need these two packages to use MongoEngine:

  • pymongo>=3.4

If you utilize a DateTimeField, you might also use a more flexible date parser:

  • dateutil>=2.1.0

If you need to use an ImageField or ImageGridFsProxy:

  • Pillow>=2.0.0

If you need to use signals:

  • blinker>=1.3

Examples

Some simple examples of what MongoEngine code looks like:

from mongoengine import *
connect('mydb')

class BlogPost(Document):
    title = StringField(required=True, max_length=200)
    posted = DateTimeField(default=datetime.datetime.utcnow)
    tags = ListField(StringField(max_length=50))
    meta = {'allow_inheritance': True}

class TextPost(BlogPost):
    content = StringField(required=True)

class LinkPost(BlogPost):
    url = StringField(required=True)

# Create a text-based post
>>> post1 = TextPost(title='Using MongoEngine', content='See the tutorial')
>>> post1.tags = ['mongodb', 'mongoengine']
>>> post1.save()

# Create a link-based post
>>> post2 = LinkPost(title='MongoEngine Docs', url='hmarr.com/mongoengine')
>>> post2.tags = ['mongoengine', 'documentation']
>>> post2.save()

# Iterate over all posts using the BlogPost superclass
>>> for post in BlogPost.objects:
...     print('===', post.title, '===')
...     if isinstance(post, TextPost):
...         print(post.content)
...     elif isinstance(post, LinkPost):
...         print('Link:', post.url)
...

# Count all blog posts and its subtypes
>>> BlogPost.objects.count()
2
>>> TextPost.objects.count()
1
>>> LinkPost.objects.count()
1

# Count tagged posts
>>> BlogPost.objects(tags='mongoengine').count()
2
>>> BlogPost.objects(tags='mongodb').count()
1

Tests

To run the test suite, ensure you are running a local instance of MongoDB on the standard port and have pytest installed. Then, run python setup.py test or simply pytest.

To run the test suite on every supported Python and PyMongo version, you can use tox. You'll need to make sure you have each supported Python version installed in your environment and then:

# Install tox
$ python -m pip install tox
# Run the test suites
$ tox

If you wish to run a subset of tests, use the pytest convention:

# Run all the tests in a particular test file
$ pytest tests/fields/test_fields.py
# Run only particular test class in that file
$ pytest tests/fields/test_fields.py::TestField

Community

Contributing

We welcome contributions! See the Contribution guidelines

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].