server: Add pagination and search

This commit is contained in:
Elias Projahn 2020-05-01 14:57:23 +02:00
parent f81c3ed940
commit a39195d2c4
5 changed files with 15 additions and 10 deletions

View file

@ -7,8 +7,9 @@ class CompositionsController extends ResourceController {
CompositionsController(this.db);
@Operation.get('id')
Future<Response> getWorks(@Bind.path('id') int id) async {
final works = await db.getWorks(id);
Future<Response> getWorks(@Bind.path('id') int id,
[@Bind.query('p') int page, @Bind.query('s') String search]) async {
final works = await db.getWorks(id, page, search);
return Response.ok(works);
}
}

View file

@ -7,8 +7,9 @@ class EnsemblesController extends ResourceController {
EnsemblesController(this.db);
@Operation.get()
Future<Response> getEnsembles() async {
final ensembles = await db.allEnsembles().get();
Future<Response> getEnsembles(
[@Bind.query('p') int page, @Bind.query('s') String search]) async {
final ensembles = await db.getEnsembles(page, search);
return Response.ok(ensembles);
}

View file

@ -7,8 +7,9 @@ class InstrumentsController extends ResourceController {
InstrumentsController(this.db);
@Operation.get()
Future<Response> getInstruments() async {
final instruments = await db.allInstruments().get();
Future<Response> getInstruments(
[@Bind.query('p') int page, @Bind.query('s') String search]) async {
final instruments = await db.getInstruments(page, search);
return Response.ok(instruments);
}

View file

@ -7,8 +7,9 @@ class PersonsController extends ResourceController {
PersonsController(this.db);
@Operation.get()
Future<Response> getPersons() async {
final persons = await db.allPersons().get();
Future<Response> getPersons(
[@Bind.query('p') int page, @Bind.query('s') String search]) async {
final persons = await db.getPersons(page, search);
return Response.ok(persons);
}

View file

@ -7,8 +7,9 @@ class WorkRecordingsController extends ResourceController {
WorkRecordingsController(this.db);
@Operation.get('id')
Future<Response> getRecordings(@Bind.path('id') int id) async {
final recordings = await db.getRecordings(id);
Future<Response> getRecordings(@Bind.path('id') int id,
[@Bind.query('p') int page]) async {
final recordings = await db.getRecordings(id, page);
return Response.ok(recordings);
}
}