
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
sanic-mongodb-extension
Advanced tools
sanic-mongodb-extension ####################### MongoDB with μMongo ODM support for Sanic framework
This package should be installed using pip: ::
pip install sanic-mongodb-extension
.. code-block:: python
#!/usr/bin/env python3
from sanic import Sanic, response
from sanic_mongodb_ext import MongoDbExtension
from umongo import Instance, Document, MotorAsyncIOInstance
from umongo.fields import StringField
app = Sanic(__name__)
# Configuration for MongoDB and uMongo
app.config.update({
"MONGODB_DATABASE": "app", # Make ensure that the `app` database is really exists
"MONGODB_URI": "mongodb://root:root@mongodb:27017",
# You can also specify custom connection options.
# For more details check the official docs: https://api.mongodb.com/python/3.7.0/api/pymongo/mongo_client.html#pymongo.mongo_client.MongoClient
"MONGODB_CONNECT_OPTIONS": {
"minPoolSize": 10,
"maxPoolSize": 50,
},
"LAZY_UMONGO": MotorAsyncIOInstance(),
})
# uMongo client is available as `app.mongodb` or `app.extensions['mongodb']`.
# The lazy client will be available as `app.lazy_mongodb` only when the database was specified,
# and which is a great choice for the structured projects.
MongoDbExtension(app)
# Describe the model
@app.lazy_umongo.register
class Artist(Document):
name = StringField(required=True, allow_none=False)
# And use it later for APIs
@app.route("/")
async def handle(request):
artist = Artist(name="A new rockstar!")
await artist.commit()
return response.json(artist.dump())
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000)
The sanic-mongodb-extension is published under BSD license. For more details read LICENSE_ file.
.. _links: .. _uMongo: https://github.com/Scille/umongo .. _motor_asyncio: https://motor.readthedocs.io/en/stable/ .. _LICENSE: https://github.com/Relrin/sanic-mongodb-extension/blob/master/LICENSE
Open Matchmaking project:
Auth/Auth microservice <https://github.com/OpenMatchmaking/microservice-auth/>
_Game servers pool microservice <https://github.com/OpenMatchmaking/microservice-game-servers-pool/>
_Player statistics microservice <https://github.com/OpenMatchmaking/microservice-player-statistics/>
_FAQs
MongoDB with μMongo ODM support for Sanic framework
We found that sanic-mongodb-extension demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.