{"id":13705549,"url":"https://github.com/Relrin/sanic-mongodb-extension","last_synced_at":"2025-05-05T16:33:07.753Z","repository":{"id":57463851,"uuid":"122643208","full_name":"Relrin/sanic-mongodb-extension","owner":"Relrin","description":"MongoDB with μMongo support for Sanic framework","archived":false,"fork":false,"pushed_at":"2023-05-10T17:27:18.000Z","size":34,"stargazers_count":27,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-29T12:20:49.942Z","etag":null,"topics":["extension","mongodb","orm","python","sanic"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Relrin.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-23T16:09:58.000Z","updated_at":"2024-06-22T17:18:43.795Z","dependencies_parsed_at":"2024-06-22T17:28:35.818Z","dependency_job_id":null,"html_url":"https://github.com/Relrin/sanic-mongodb-extension","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relrin%2Fsanic-mongodb-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relrin%2Fsanic-mongodb-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relrin%2Fsanic-mongodb-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relrin%2Fsanic-mongodb-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Relrin","download_url":"https://codeload.github.com/Relrin/sanic-mongodb-extension/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224455887,"owners_count":17314200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["extension","mongodb","orm","python","sanic"],"created_at":"2024-08-02T22:00:43.485Z","updated_at":"2024-11-13T13:30:38.388Z","avatar_url":"https://github.com/Relrin.png","language":"Python","funding_links":[],"categories":["Extensions"],"sub_categories":["ORM"],"readme":"sanic-mongodb-extension\n#######################\nMongoDB with μMongo ODM support for Sanic framework\n\nFeatures\n========\n- Uses motor_asyncio_ package for async queries to MongoDB\n- Good integrated with uMongo_ ODM, so that you can use it easily in your projects\n\nInstallation\n============\nThis package should be installed using pip: ::\n\n    pip install sanic-mongodb-extension\n\nExample\n=======\n.. code-block:: python\n\n    #!/usr/bin/env python3\n    from sanic import Sanic, response\n    from sanic_mongodb_ext import MongoDbExtension\n    from umongo import Instance, Document\n    from umongo.fields import StringField\n    from umongo.frameworks import MotorAsyncIOInstance\n\n    app = Sanic(__name__)\n    # Configuration for MongoDB and uMongo\n    app.config.update({\n        \"MONGODB_DATABASE\": \"app\", # Make ensure that the `app` database is really exists\n        \"MONGODB_URI\": \"mongodb://root:root@mongodb:27017\",\n        # You can also specify custom connection options.\n        # For more details check the official docs: https://api.mongodb.com/python/3.7.0/api/pymongo/mongo_client.html#pymongo.mongo_client.MongoClient\n        \"MONGODB_CONNECT_OPTIONS\": {\n            \"minPoolSize\": 10,\n            \"maxPoolSize\": 50,\n        },\n        \"LAZY_UMONGO\": MotorAsyncIOInstance(),\n    })\n    # uMongo client is available as `app.ctx.mongodb` or `app.ctx.extensions['mongodb']`.\n    # The lazy client will be available as `app.ctx.lazy_mongodb` only when the database was specified,\n    # and which is a great choice for the structured projects.\n    MongoDbExtension(app)\n\n\n    # Describe the model\n    @app.ctx.lazy_umongo.register\n    class Artist(Document):\n        name = StringField(required=True, allow_none=False)\n\n\n    # And use it later for APIs\n    @app.route(\"/\")\n    async def handle(request):\n        artist = Artist(name=\"A new rockstar!\")\n        await artist.commit()\n        return response.json(artist.dump())\n\n\n    if __name__ == '__main__':\n        app.run(host='0.0.0.0', port=8000)\n\nLicense\n=======\nThe sanic-mongodb-extension is published under BSD license. For more details read LICENSE_ file.\n\n.. _links:\n.. _uMongo: https://github.com/Scille/umongo\n.. _motor_asyncio: https://motor.readthedocs.io/en/stable/\n.. _LICENSE: https://github.com/Relrin/sanic-mongodb-extension/blob/master/LICENSE\n\nReal project examples\n=====================\nOpen Matchmaking project:  \n\n- `Auth/Auth microservice \u003chttps://github.com/OpenMatchmaking/microservice-auth/\u003e`_\n- `Game servers pool microservice \u003chttps://github.com/OpenMatchmaking/microservice-game-servers-pool/\u003e`_\n- `Player statistics microservice \u003chttps://github.com/OpenMatchmaking/microservice-player-statistics/\u003e`_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRelrin%2Fsanic-mongodb-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRelrin%2Fsanic-mongodb-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRelrin%2Fsanic-mongodb-extension/lists"}