Skip to content

Instantly share code, notes, and snippets.

@mikeywaites
Created November 22, 2017 08:19
Show Gist options
  • Save mikeywaites/1881bb77fe2ffeba202602ec29e3e822 to your computer and use it in GitHub Desktop.
Save mikeywaites/1881bb77fe2ffeba202602ec29e3e822 to your computer and use it in GitHub Desktop.
from arrested import Resource
from arrested.contrib.kim_arrested import KimEndpoint
from arrested.contrib.sql_alchemy import DBListMixin, DBCreateMixin
from star_wars.models import db, Character
from .mappers import CharacterMapper
characters_resource = Resource('characters', __name__, url_prefix='/characters')
class CharactersIndexEndpoint(KimEndpoint, DBListMixin, DBCreateMixin):
name = 'list'
many = True
mapper_class = CharacterMapper
model = Character
def get_query(self):
stmt = db.session.query(Character)
return stmt
characters_resource.add_endpoint(CharactersIndexEndpoint)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment