Wrappers#
- class quart_mongo.wrappers.AIOMotorCollection(database: AIOMotorDatabase, name: str, codec_options: CodecOptions | None = None, read_preference: _ServerMode | None = None, write_concern: WriteConcern | None = None, read_concern: ReadConcern | None = None, _delegate: Any | None = None)#
Subclass of the
AsyncIOMotorCollectionwith helpers.- async find_one_or_404(*args: Any, **kwargs: Any) Dict#
Find a single document or raise a 404 with the browser.
This function is like AsyncIOMotorCollection.Collection.find_one, but rather than returning
None. It will raise a 404 error (Not Found HTTP status) on the request.- Parameters:
args – Arguments to be passed to AsyncIOMotorCollection.Collection.find_one.
kwargs – Extra arguments to be passed to AsyncIOMotorCollection.Collection.find_one.
- class quart_mongo.wrappers.AIOMotorDatabase(client: AIOMotorClient, name: str, **kwargs: Any)#
Subclass of
AsyncIOMotorDatabase.Returns instances
AsyncMotorCollectioninstead of nativeAsyncIOMotorCollectionwhen accessed with dot notation.- Parameters:
client – An instance of the Motor client to use to connect to the database.
name – The name of the database.
kwargs – Extra arguments to be passed to the database.
- class quart_mongo.wrappers.AIOEngine(client: AsyncIOMotorClient | None = None, database: str = 'test')#
Subclass of the :class`~Odmantic.AIOEngine` object, which is responsible for handling database operations with MongoDB in an asynchronous way using Motor.
The purpose of this subclass is to add the function :func::AIOEngine.find_one_or_404.
- async find_one_or_404(model: Type[ModelType], *queries: QueryExpression | Dict | bool, sort: Any | None = None, session: Any | None = None) Model#
Find a single document or raise a 404 with the browser.
This function is like
find_one(), but rather than returningNone. It will raise a 404 error (Not Found HTTP status) on the request.- Parameters:
model – The
Modelto use to find the model.args – Arguments to pass to
find_one.kwargs – Extra arguments to pass to
:param
find_one.:- Raises:
HTTPException – Uses quart.abort to raises this exception if
there is not entry found in the database. This will raise a 404 –
error code with the browser. –
- class quart_mongo.wrappers.AIOMotorClient(*args, **kwargs)#
Subclass of
AsyncIOMotorClient.Returns instances of Quart-Mongo
AIOMotorDatabaseinstead of nativeAIOMotorDatabase.AIOEngineinstead of nativeAIOEngine.- motor(name: str) AIOMotorDatabase#
Returns an instance of
AIOMotorDatabase.