{"id":24362366,"url":"https://github.com/machu-gwu/mongoengine_mate-project","last_synced_at":"2026-03-10T07:04:44.906Z","repository":{"id":82575642,"uuid":"106239555","full_name":"MacHu-GWU/mongoengine_mate-project","owner":"MacHu-GWU","description":"A library extend power of mongoengine.","archived":false,"fork":false,"pushed_at":"2019-12-27T17:41:34.000Z","size":122,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-12T05:18:41.728Z","etag":null,"topics":["database","mongodb","orm","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MacHu-GWU.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.rst","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-09T05:20:12.000Z","updated_at":"2022-09-08T09:36:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"167ccc0d-2106-4654-a91a-6759d8bb8cd2","html_url":"https://github.com/MacHu-GWU/mongoengine_mate-project","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MacHu-GWU/mongoengine_mate-project","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacHu-GWU%2Fmongoengine_mate-project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacHu-GWU%2Fmongoengine_mate-project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacHu-GWU%2Fmongoengine_mate-project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacHu-GWU%2Fmongoengine_mate-project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MacHu-GWU","download_url":"https://codeload.github.com/MacHu-GWU/mongoengine_mate-project/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacHu-GWU%2Fmongoengine_mate-project/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30326893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T05:25:20.737Z","status":"ssl_error","status_checked_at":"2026-03-10T05:25:17.430Z","response_time":106,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","mongodb","orm","python"],"created_at":"2025-01-18T22:51:52.438Z","updated_at":"2026-03-10T07:04:44.887Z","avatar_url":"https://github.com/MacHu-GWU.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n.. image:: https://readthedocs.org/projects/mongoengine_mate/badge/?version=latest\n    :target: https://mongoengine_mate.readthedocs.io/index.html\n    :alt: Documentation Status\n\n.. image:: https://travis-ci.org/MacHu-GWU/mongoengine_mate-project.svg?branch=master\n    :target: https://travis-ci.org/MacHu-GWU/mongoengine_mate-project?branch=master\n\n.. image:: https://codecov.io/gh/MacHu-GWU/mongoengine_mate-project/branch/master/graph/badge.svg\n  :target: https://codecov.io/gh/MacHu-GWU/mongoengine_mate-project\n\n.. image:: https://img.shields.io/pypi/v/mongoengine_mate.svg\n    :target: https://pypi.python.org/pypi/mongoengine_mate\n\n.. image:: https://img.shields.io/pypi/l/mongoengine_mate.svg\n    :target: https://pypi.python.org/pypi/mongoengine_mate\n\n.. image:: https://img.shields.io/pypi/pyversions/mongoengine_mate.svg\n    :target: https://pypi.python.org/pypi/mongoengine_mate\n\n.. image:: https://img.shields.io/badge/STAR_Me_on_GitHub!--None.svg?style=social\n    :target: https://github.com/MacHu-GWU/mongoengine_mate-project\n\n------\n\n\n.. image:: https://img.shields.io/badge/Link-Document-blue.svg\n      :target: https://mongoengine_mate.readthedocs.io/index.html\n\n.. image:: https://img.shields.io/badge/Link-API-blue.svg\n      :target: https://mongoengine_mate.readthedocs.io/py-modindex.html\n\n.. image:: https://img.shields.io/badge/Link-Source_Code-blue.svg\n      :target: https://mongoengine_mate.readthedocs.io/py-modindex.html\n\n.. image:: https://img.shields.io/badge/Link-Install-blue.svg\n      :target: `install`_\n\n.. image:: https://img.shields.io/badge/Link-GitHub-blue.svg\n      :target: https://github.com/MacHu-GWU/mongoengine_mate-project\n\n.. image:: https://img.shields.io/badge/Link-Submit_Issue-blue.svg\n      :target: https://github.com/MacHu-GWU/mongoengine_mate-project/issues\n\n.. image:: https://img.shields.io/badge/Link-Request_Feature-blue.svg\n      :target: https://github.com/MacHu-GWU/mongoengine_mate-project/issues\n\n.. image:: https://img.shields.io/badge/Link-Download-blue.svg\n      :target: https://pypi.org/pypi/mongoengine_mate#files\n\n\nWelcome to ``mongoengine_mate`` Documentation\n==============================================================================\n\n``mongoengine_mate`` includes lots more utility method in ORM model Class, makes ``mongoengine`` more powerful.\n\n\nUsage\n------------------------------------------------------------------------------\n\n.. code-block:: python\n\n    import mongoengine\n    from mongoengine_mate import ExtendedDocument\n\n    class User(ExtendedDocument):\n        id = mongoengine.IntField()\n        name = mongoengine.StringField()\n\n\nFirst, you got better ``__repr__()`` like:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e User(id=1, name=\"Alice\")\n    User(id=1, name=\"Alice\")\n\n    # access its collection or database\n    \u003e\u003e\u003e col_user = User.col()\n    \u003e\u003e\u003e col_user.find({\"_id\": 1})\n    \u003e\u003e\u003e col_db = User.db()\n\n    # access its field name in order\n    \u003e\u003e\u003e User.fields_ordered()\n    [\"id\", \"name\"]\n\n    # provide dictionary-like api\n    \u003e\u003e\u003e user = User(id=1, name=\"Alice\")\n    \u003e\u003e\u003e user.keys()\n    [\"id\", \"name\"]\n\n    \u003e\u003e\u003e user.values()\n    [1, \"Alice\"]\n\n    \u003e\u003e\u003e user.items()\n    [(\"id\", \"name\"), (1, \"Alice\")]\n\n    \u003e\u003e\u003e user.to_dict()\n    {\"id\": 1, \"name\": \"Alice\"}\n\n    \u003e\u003e\u003e user.to_OrderedDict()\n    OrderedDict([(\"id\", \"name\"), (1, \"Alice\")])\n\n\nSmart Insert - Skip Primary Key Conflict\n------------------------------------------------------------------------------\n\nWhen you do batch insert, sometimes one or a few documents may cause ``_id`` field conflict error, which is breaking the batch insert operation.\n\nUsually you have to write a ``for loop` and use ``try ... except ...`` to ignore conflict. But, it is SLOW!\n\n``ExtendedDocument.smart_insert`` provides a fast and convenient way to batch insert lots of document at once correctly.\n\n.. code-block:: python\n\n    # insert one document which breaks the batch insert\n    User(id=100, name=\"Obama\").save()\n\n    # smart_insert, automatically handle NotUniqueError\n    User.smart_insert([\n        User(id=1, name=\"Alice\"),\n        User(id=2, name=\"Bob\"),\n        ...\n        User(id=1000, name=\"Zillow\"),\n    ])\n\n\nSmart Update - Batch Upsert\n------------------------------------------------------------------------------\n\nWhen you do batch update, you mostly want to use the ``_id`` field to locate which document you want to update.\n\n.. code-block:: python\n\n    \u003e\u003e\u003eUser(id=2, name=\"Bob\").save()\n\n    # update only\n    \u003e\u003e\u003e User.smart_update([\n        User(id=1, name=\"Alice\"),\n        User(id=2, name=\"Bruce\"),\n        User(id=3, name=\"Cathy\"),\n    ], upsert=False)\n    \u003e\u003e\u003e User.objects.count()\n    1\n\n    # upsert\n    \u003e\u003e\u003e User.smart_update([\n        User(id=1, name=\"Alice\"),\n        User(id=2, name=\"Bruce\"),\n        User(id=3, name=\"Cathy\"),\n    ], upsert=True)\n    \u003e\u003e\u003e User.objects.count()\n    3\n\n\n.. _install:\n\nInstall\n------------------------------------------------------------------------------\n\n``mongoengine_mate`` is released on PyPI, so all you need is:\n\n.. code-block:: console\n\n    $ pip install mongoengine_mate\n\nTo upgrade to latest version:\n\n.. code-block:: console\n\n    $ pip install --upgrade mongoengine_mate","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmachu-gwu%2Fmongoengine_mate-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmachu-gwu%2Fmongoengine_mate-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmachu-gwu%2Fmongoengine_mate-project/lists"}