Skip to content

Instantly share code, notes, and snippets.

@mikeywaites
Last active January 17, 2018 03:48
Show Gist options
  • Save mikeywaites/fdea7105060e829153384fff2ab16654 to your computer and use it in GitHub Desktop.
Save mikeywaites/fdea7105060e829153384fff2ab16654 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
from star_wars.models import db, Character
from .mappers import CharacterMapper
characters_resource = Resource('characters', __name__, url_prefix='/characters')
class CharactersIndexEndpoint(KimEndpoint, DBListMixin):
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