Authentication
Response
Response Example
Data Aggregation Process
- Fetch Educator Courses: Retrieves all courses created by the authenticated educator
- Calculate Total Courses: Counts the number of courses
- Calculate Total Earnings:
- Finds all completed purchases for the educator’s courses
- Sums the
amountfield from all purchases
- Collect Enrolled Students:
- Extracts all student IDs from course enrollment lists
- Fetches student details (name and image) from the User collection
- Maps students to their enrolled courses
- Returns array with course title and student information
Notes
- Only completed purchases are included in earnings calculations
- Students enrolled in multiple courses will appear multiple times in
enrolledStudentsData - The same student can appear under different courses
- Student data includes only
nameandimageUrlfields for privacy - If a student’s data cannot be found, they are filtered out from the results
Use Cases
- Display educator dashboard overview
- Show total revenue and course statistics
- List all students across all courses
- Identify which courses have the most enrollments
Error Response
Performance Considerations
- The endpoint performs multiple database queries:
- Course query (filtered by educatorId)
- Purchase query (filtered by courseIds with completed status)
- User query (batch fetch for all enrolled students)
- Results are optimized using:
- Object mapping for efficient student lookups
flatMapfor collecting students across courses- Filtering to remove invalid student references