amplify-flutter
amplify-flutter copied to clipboard
feat(api): add listByIndex to ModelQueries
Issue #4942
Description of changes:
- Add listByIndex to ModelQueries, it's build on
list
, required parameters are:classType
andqueryField
, optional fields aresortDirection
,indexName
,overrideQueryFieldType
.
Usage:
ModelQueries.listByIndex(
TaskComment.classType,
queryField: taskId,
/// sortDirection: "ASC", /// ASC or DESC, default is DESC
/// indexName: "taskCommentsByDate", /// It's getting first secondary index in schema, if you have more, specify secondary index name
/// overrideQueryFieldType: "String!", /// It's for queryField's type, it should be match for GraphQL validation, autogenerated gen1 belongsTo fields are `ID!`
/// customQueryName: "listTasksCommentsByDate" /// It's optional. On Gen1 user provide query name, on gen 2 it's generating automatically.
/// where: TaskComment.TASK.eq(taskId), /// It cannot be used, if secondary index's queryField is taskId, you cannot use where taskId at the same time,
);
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.