Authentication
Response
Response Example
Data Collection Process
- Fetch Educator Courses: Retrieves all courses created by the authenticated educator
- Extract Course IDs: Creates an array of course IDs for purchase lookup
- Query Purchases:
- Finds all purchases matching the educator’s course IDs
- Filters for only completed purchases
- Populates student information (
nameandimageUrl) - Populates course information (
courseTitle)
- Transform Data: Maps purchase records to enrollment objects containing:
- Student details
- Course title
- Purchase date (from
createdAtfield)
Key Differences from Dashboard Endpoint
While the/dashboard endpoint provides aggregated statistics, this endpoint offers:
- Purchase timestamps: Exact date and time of each enrollment
- Individual purchase records: Each purchase is a separate entry
- Complete purchase history: All completed transactions, not just enrolled students
- Chronological data: Useful for tracking enrollment trends over time
Use Cases
- Display detailed student enrollment tables
- Track enrollment trends and purchase history
- Generate reports on course purchases
- Show recent student enrollments
- Export enrollment data for analysis
- Identify popular courses by purchase frequency
Filtering and Sorting
The endpoint currently returns all completed purchases. To filter or sort the data:Error Response
Notes
- Only completed purchases are included (pending or failed purchases are excluded)
- Students who purchased multiple courses will have multiple entries
- The
purchaseDatefield uses thecreatedAttimestamp from the Purchase model - Student information is populated from the User collection via the
userIdreference - Course information is populated from the Course collection via the
courseIdreference
Performance Considerations
- Uses MongoDB population to efficiently join related collections
- Filters at the database level for optimal performance
- Returns only necessary student fields (
name,imageUrl) to reduce payload size