WayrApp Backend & Ecosystem Documentation - v1.0.0
    Preparing search index...

    Function createPaginationMeta

    • Creates standardized pagination metadata object from basic parameters.

      This utility function calculates all pagination-related metadata including total pages, navigation flags, and offset values from the basic page, limit, and total count parameters. It provides a consistent pagination metadata structure used throughout the application.

      Parameters

      • page: number

        Current page number (1-based)

      • limit: number

        Number of items per page

      • total: number

        Total number of items in the dataset

      Returns {
          page: number;
          limit: number;
          total: number;
          totalPages: number;
          hasNext: boolean;
          hasPrev: boolean;
          offset: number;
      }

      Pagination metadata object

      // Creating pagination metadata in service layer
      const total = await prisma.course.count(whereClause);
      const paginationMeta = createPaginationMeta(page, limit, total);
      return { data: courses, pagination: paginationMeta };