How to use the awokado.consts.READ function in awokado

To help you get started, we’ve selected a few awokado examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 5783354 / awokado / tests / test_app / resources / store_stats.py View on Github external
import sqlalchemy as sa
from marshmallow import fields

import tests.test_app.models as m
from awokado.consts import READ
from awokado.meta import ResourceMeta
from awokado.resource import BaseResource


class StoreStatsResource(BaseResource):
    Meta = ResourceMeta(
        model=m.Store,
        name="store_stats",
        methods=(READ,),
        select_from=sa.outerjoin(
            m.Store, m.Book, m.Store.id == m.Book.store_id
        ),
    )

    name = fields.String(model_field=m.Store.name)
    books_count = fields.Int(
        dump_only=True, model_field=sa.func.count(m.Book.id)
    )
github 5783354 / awokado / tests / test_app / resources / tag_stats.py View on Github external
import sqlalchemy as sa
from marshmallow import fields

import tests.test_app.models as m
from awokado.consts import READ
from awokado.meta import ResourceMeta
from awokado.resource import BaseResource


class TagStatsResource(BaseResource):
    Meta = ResourceMeta(
        model=m.Tag,
        name="tag_stats",
        methods=(READ,),
        disable_total=True,
        select_from=sa.outerjoin(
            m.Tag, m.M2M_Book_Tag, m.Tag.id == m.M2M_Book_Tag.c.tag_id
        ).outerjoin(m.Book, m.M2M_Book_Tag.c.book_id == m.Book.id),
        id_field="name",
    )

    name = fields.String(model_field=m.Tag.name)
    books_count = fields.Int(
        dump_only=True, model_field=sa.func.count(m.Book.id)
    )