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

160
Views
¿Cómo reemplazar una cadena en todos los registros usando Robo 3T?

Estoy usando MongoDB y Robo 3T. En algunos documentos tengo un parent de campo con el valor "0" (cadena). Quiero reemplazarlo con "NA" . Para obtener todos los registros que hice:

 db.getCollection('mycollection').find({}).forEach(function(doc) { var json = JSON.stringify( doc ); if ( json.match(/"parent":"0"/) != null ) { printjson(doc); } });

Ahora, ¿cómo puedo reemplazar el "parent":"0" con "parent":"NA" en todos los registros?

EDITAR : Otro intento:

 db.getCollection('mycollection').find({}).forEach(function(doc) { var json = JSON.stringify( doc ); if ( json.match(/"parent":"0"/) != null ) { var obj = JSON.parse(json, (key, value) => { return (key === 'parent' && value === '0') ? value.replace('0', 'NA') : value; }); } //doc = obj; printjson(obj); });

que funciona Pero actualizar el registro haciendo doc = obj no funciona. ¿Como arreglarlo?

over 4 years ago · Santiago Trujillo
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!