Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

285
Vistas
Replace string in one node of Mongodb document

I need your help to write one replace query. I have connected one third party software mongodb. I am SQL guy and not able to write query of replace specific node value.

I am using Robo 3T software. Below is one record json from the document.

{
    "_id" : ObjectId("6036c343445f3640c53e0a"), 
    "shares" : [ 
        {
            "shareId" : ObjectId("6035cc6acf345f3640c53d1a"),
            "type" : "user"
        }, 
        {
            "shareId" : ObjectId("6035b536cf345f3640c53cae"),
            "type" : "group",
            "rule" : "view",
            "subscribe" : false
        }
    ],
    "tags" : [],
    "lastUsed" : ISODate("2021-03-09T16:51:30.059Z"),
    "usageCount" : 1,
    "layout" : {
       too many values with multiple node.
    },
    "instanceType" : "owner",
    "original" : null,
    "editing" : true,
    "filters" : [ 
        {
            "jaql" : {
                "table" : "Xyz",
                "column" : "title",
                **"dim" : "[dbo.ketan.Title]",**
                }
            }
            "disabled" : false
        }, 
        {
            "jaql" : {
                "table" : "abc",
                "column" : "name",
                **"dim" : "[dbo.ketan.name]",**
                "datatype" : "text",
                "merged" : true,
                "title" : "Inventor Name",
                "filter" : {
                    "explicit" : false,
                    "multiSelection" : true,
                    "all" : true
                },
                "collapsed" : false
            },
            "instanceid" : "1B1E4-F6DC-28",
            "isCascading" : false
        }, 
        
}

Here I want to replace "dim" : "[dbo.ketan.name]", to "dim" : "[kiran.name]",

Can you please help me to write query ?

This is my first post. The Writing may be not up to mark. Please let me know if you need any more details.

Thank you.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

This is how you can acheive the functionality. Although your MongoDB Version should be >= 3.6

db.collection.update(                                     //collection
  {"filters.jaql.dim": {"$regex": "dbo.ketan"}},          //update filter
  {"$set": {"filters.$[elem].jaql.dim": "[kiran.name]"}}, //update action
  {
    "arrayFilters": [
      {
        "elem.jaql.dim": {
          "$regex": "dbo.ketan"
        }
      }],
    "multi": true
  }                                               //filters for all element to be updated
)

To see this logic in action: MongoPlayground Example

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda