Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/turbogears/ming
MongoDB ODM (Object Document Mapper) with Unit of Works, IdentityMap, Relations and Mongo-In-Memory implementation
https://github.com/turbogears/ming
in-memory mongodb odm orm pymongo python
Last synced: about 17 hours ago
JSON representation
MongoDB ODM (Object Document Mapper) with Unit of Works, IdentityMap, Relations and Mongo-In-Memory implementation
- Host: GitHub
- URL: https://github.com/turbogears/ming
- Owner: TurboGears
- License: other
- Created: 2018-04-28T20:08:50.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-23T18:01:45.000Z (21 days ago)
- Last Synced: 2024-11-06T08:09:02.970Z (8 days ago)
- Topics: in-memory, mongodb, odm, orm, pymongo, python
- Language: Python
- Homepage: https://ming.readthedocs.io
- Size: 1.18 MB
- Stars: 28
- Watchers: 8
- Forks: 17
- Open Issues: 11
-
Metadata Files:
- Readme: README.rst
- Changelog: NEWS
- License: LICENSE.txt
Awesome Lists containing this project
README
Ming
====.. image:: https://github.com/TurboGears/Ming/actions/workflows/main.yml/badge.svg
:target: https://github.com/TurboGears/Ming/actions/workflows/main.yml.. image:: https://codecov.io/gh/TurboGears/Ming/branch/master/graph/badge.svg?token=Iy3CU62Ga5
:target: https://codecov.io/gh/TurboGears/Ming.. image:: https://img.shields.io/pypi/v/Ming.svg
:target: https://pypi.python.org/pypi/Ming.. image:: https://img.shields.io/pypi/pyversions/Ming.svg
:target: https://pypi.python.org/pypi/Ming.. image:: https://img.shields.io/pypi/l/Ming.svg
:target: https://pypi.python.org/pypi/Ming.. image:: https://img.shields.io/gitter/room/turbogears/Lobby.svg
:target: https://gitter.im/turbogears/Lobby.. image:: https://img.shields.io/twitter/follow/turbogearsorg.svg?style=social&label=Follow
:target: https://twitter.com/turbogearsorgMing is a MongoDB ODM ( Object Document Mapper, like an ORM but for Document based databases),
that builds on top of ``pymongo`` by extending it with:* Declarative Models
* Schema Validation and Conversion
* Lazy Schema Evolution
* Unit of Work
* Identity Map
* One-To-Many, Many-To-One and Many-To-Many Relations
* Pure InMemory MongoDB ImplementationMing is the official MongoDB support layer of `TurboGears `_ web
framework, thus feel free to join the TurboGears Gitter or Twitter to discuss Ming.If you want to dig further in Ming, documentation is available
at http://ming.readthedocs.io/en/latest/Getting Started
---------------To use Ming you need to create a ``Session`` and a few models that
should be managed by it::from ming import create_datastore, schema
from ming.odm import ThreadLocalODMSession, Mapper, MappedClass, FieldPropertysession = ThreadLocalODMSession(
bind=create_datastore('mongodb://localhost:27017/dbname')
)class WikiPage(MappedClass):
class __mongometa__:
session = session
name = 'wiki_page'_id = FieldProperty(schema.ObjectId)
title = FieldProperty(schema.String(required=True))
text = FieldProperty(schema.String(if_missing=''))Mapper.compile_all()
Then you can create and query those models::
>>> WikiPage(title='FirstPage', text='This is a page')
>>> session.flush() # Flush session to actually create wikipage.
>>> wp = WikiPage.query.find({'text': 'This is a page'}).first()
>>> print(wp)