Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
El gancho mangosta .pre() no se activa como debería

Estoy tratando de cambiar un campo de un documento a medida que se actualiza otro, pero por alguna razón que no veo, no sucede.

El campo "marcado" obtiene el valor del campo "contenido" a medida que se crea el documento, como debería ser, pero cuando el documento se actualiza, el valor del campo "marcado" no se actualiza.

(Estoy usando marcado y sanitize-html para renderizar el descuento)

 const mongoose = require('mongoose') const marked = require('marked') const sanitizeHtml = require('sanitize-html') const postSchema = new mongoose.Schema({ title: { type: String, required: true }, desc: { type: String }, content: { type: String, required: true }, marked: { type: String, required: true } }); postSchema.pre('validate', function(next) { // alredy tried save, and updateOne if (this.content) { this.marked = sanitizeHtml(marked.parse(this.content)) } next() }) module.exports = mongoose.model('Post', postSchema)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!