getRoutesByUser method

Future<List<RaliRoute>> getRoutesByUser(
  1. String userId
)

Gets routes created by a specific user

Implementation

Future<List<RaliRoute>> getRoutesByUser(String userId) async {
  try {
    final querySnapshot = await _firestore
        .collection(_collectionPath)
        .where('createdBy', isEqualTo: userId)
        .get();

    return querySnapshot.docs.map((doc) =>
        RaliRoute.fromMap(doc.data(), doc.id)
    ).toList();
  } catch (e) {
    print('Error getting user routes: $e');
    rethrow;
  }
}