amplify-flutter icon indicating copy to clipboard operation
amplify-flutter copied to clipboard

feat(api): add listByIndex to ModelQueries

Open MarlonJD opened this issue 8 months ago • 0 comments

Issue #4942

Description of changes:

  • Add listByIndex to ModelQueries, it's build on list, required parameters are: classType and queryField, optional fields are sortDirection, 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.

MarlonJD avatar May 31 '24 08:05 MarlonJD