getPrerequisites method

Future<List<TopicPrerequisite>> getPrerequisites(
  1. String topicId
)

Fetch prerequisite topics for a given topic.

Implementation

Future<List<TopicPrerequisite>> getPrerequisites(String topicId) async {
  final response = await _client
      .from('topic_prerequisites')
      .select('topic_id, prerequisite_topic_id, strength')
      .eq('topic_id', topicId);
  return (response as List).map((e) {
    final row = e as Map<String, dynamic>;
    return TopicPrerequisite(
      topicId: row['topic_id'] as String,
      prerequisiteTopicId: row['prerequisite_topic_id'] as String,
      strength: row['strength'] as String,
    );
  }).toList();
}