Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Distribuidos-Org/ms-alumnos/llms.txt

Use this file to discover all available pages before exploring further.

Send a find_all_alumnos message to retrieve a paginated list of student records from the database. The service uses TypeORM’s findAndCount method to return both the data slice and the total record count in a single query. Both page and limit are optional and default to 1 and 10 respectively when omitted.

Message pattern

{ "cmd": "find_all_alumnos" }

Request payload

page
number
Page number to retrieve. Must be a positive integer. Defaults to 1 when omitted.
limit
number
Number of records to return per page. Must be a positive integer. Defaults to 10 when omitted.

Response

data
Alumno[]
Array of alumno records for the requested page.
total
number
Total number of alumno records currently in the database, regardless of the requested page or limit.
page
number
The current page number reflected in this response.
limit
number
The page size used to produce this response.
Each Alumno object in data includes a contrasena field containing the bcrypt hash of the student’s password. Callers should discard or ignore this field; never display or forward the hash to end users.

Example

import { connect, JSONCodec } from 'nats';

const nc = await connect({ servers: 'nats://localhost:4222' });
const jc = JSONCodec();

const res = await nc.request(
  'find_all_alumnos',
  jc.encode({ page: 1, limit: 20 }),
  { timeout: 5000 }
);

const { data, total, page, limit } = jc.decode(res.data) as any;
console.log(`Page ${page}: ${data.length} of ${total} total records`);
await nc.drain();

Pagination math

Use total and limit from the response to calculate the total number of available pages:
const totalPages = Math.ceil(total / limit);
For example, if total is 95 and limit is 20, there are Math.ceil(95 / 20) = 5 pages. The last page (page: 5) will contain only 15 records.
To iterate through all records programmatically, start at page: 1 and keep incrementing until page > Math.ceil(total / limit).

Errors

StatusCause
400page or limit is not a positive number (e.g. 0, -1, or a non-numeric string).

Build docs developers (and LLMs) love