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 an update_alumno message to partially update an existing student record. The payload must include the id of the target record; all other fields from CreateAlumnoDto are optional. The service uses TypeORM’s preload method to merge only the supplied fields into the existing entity before saving. If no record is found for the given id, the service throws an RpcException with HTTP status 404.

Message pattern

{ "cmd": "update_alumno" }

Request payload

UpdateAlumnoDto extends PartialType(CreateAlumnoDto), making every CreateAlumnoDto field optional while adding a required id.
id
number
required
The alumnoId of the student record to update. Must be a positive integer.
nombre
string
First name. Minimum 2 characters, maximum 50 characters.
apellidoPaterno
string
Paternal surname. Minimum 2 characters, maximum 50 characters.
apellidoMaterno
string
Maternal surname. Maximum 50 characters.
dni
string
National ID number. Must be exactly 8 characters. Must remain unique.
edad
number
Age of the student. Must be an integer.
email
string
Email address. Must be a valid email format. Maximum 100 characters. Must remain unique.
celular
string
Phone number. Maximum 15 characters.
universidad
string
University name. Maximum 100 characters.
facultad
string
Faculty or school name. Maximum 100 characters.
profesion
string
Profession. Maximum 50 characters.
grado
string
Academic degree. Maximum 50 characters.
egresadoLocal
boolean
Whether the student graduated locally.
contrasena
string
New password in plaintext. Minimum 6 characters, maximum 60 characters. See the warning below before using this field.

Response

The updated Alumno entity reflecting all applied changes.
alumnoId
number
Primary key of the student record.
nombre
string
First name of the student.
apellidoPaterno
string
Paternal surname.
apellidoMaterno
string
Maternal surname. May be null.
dni
string
National ID number (8 characters).
edad
number
Age of the student. May be null.
email
string
Email address.
celular
string
Phone number. May be null.
universidad
string
University name.
facultad
string
Faculty or school name. May be null.
profesion
string
Profession. May be null.
grado
string
Academic degree. May be null.
egresadoLocal
boolean
Whether the student graduated locally.
The response includes a contrasena field containing the stored value of the student’s password (a bcrypt hash for unmodified passwords, or plaintext if contrasena was included in this update — see the warning below). Callers should discard or ignore this field.

Example

import { connect, JSONCodec } from 'nats';

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

const res = await nc.request(
  'update_alumno',
  jc.encode({
    id: 1,
    facultad: 'Facultad de Ingeniería de Sistemas',
    grado: 'Magíster',
  }),
  { timeout: 5000 }
);

console.log(jc.decode(res.data));
await nc.drain();

Errors

StatusCause
404No alumno exists with the given id. The exception payload is { "status": 404, "message": "Alumno #1 not found" }.
400Validation failed on one or more supplied fields (e.g. a string exceeds its maximum length, email is malformed, dni is not 8 characters, or contrasena is shorter than 6 characters).
Updating contrasena via this message does NOT re-hash the password. The @BeforeInsert() bcrypt hook on the Alumno entity only fires during an initial insert, not on subsequent saves. Sending a new contrasena value through update_alumno will overwrite the stored hash with the plaintext string. To update a password securely, implement a dedicated password-change handler that calls bcrypt.hash() explicitly before saving.

Build docs developers (and LLMs) love