def get_collection(request: web.Request):
"""
Fetch resources collection, render JSON API document and return response.
Uses the :meth:`~aiohttp_json_api.schema.BaseSchema.query_collection`
method of the schema to query the resources in the collection.
:seealso: http://jsonapi.org/format/#fetching
"""
ctx = JSONAPIContext(request)
resources = await ctx.controller.query_collection()
compound_documents = None
if ctx.include and resources:
compound_documents, relationships = \
await get_compound_documents(resources, ctx)
result = await render_document(resources, compound_documents, ctx)
return jsonapi_response(result)
评论列表
文章目录