Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jcn-488 Adaptar metodo multiUpdate para que acepte multiples operadores y operaciones con pipeline aggregation #41

Merged
merged 5 commits into from
Jun 26, 2024

Conversation

calandrajose
Copy link
Contributor

historia

subtarea

Descripcion del requerimiento:

Se requiere modificar el metodo multiUpdate para que acepte pipelines y multiples operadores (hoy automaticamente asigna lo recibido a un $set) dentro de los valores a actualizar en cada operacion.

Como probar

Dejo pruebas en playground
Funcionamiento con pipelines
Funcionamiento con updates normales (funcionamiento vigente y que debe continuar)

Changelog:

## Changed
- MultiUpdate method now accepts all available update operators and operations with pipeline aggregations

Copy link
Contributor

@Alejandro-Gonzalez Alejandro-Gonzalez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UN com

lib/mongodb.js Outdated

if(!data || !Object.keys(data).length)
throw new MongoDBError('Every operation must have data to update', MongoDBError.codes.INVALID_ITEM);

const { id, dateModified, dateCreated, ...dataToUpdate } = data; // to avoid overriding
const operationData = Array.isArray(data) ? [...data] : [data];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@calandrajose en multiUpdate y update hace casi lo mismo podemos hacer un método que haga esto de formatear la data y que valide data y filtro si es de multiUpdate con segun el un parametro que le pases y que el metodo te devuelvan el updatedData y updateMethod

@manuelvilche manuelvilche merged commit decf56b into master Jun 26, 2024
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants