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

148
Vistas
MongoServerError: Cannot create field 'approved' in element

I want to push element inside array which is inside nested element.
Similar questions have been asked. I tried the solutions but didn't worked for me.
Error message is

MongoServerError: Cannot create field 'approved' in 
element {transactionList: [ { id: 0, greeterAddress: "0x0", executed: 0, value: 
"namaste", approved: [ "0xDcb980b3d6Bd61a86A8d7Cb9bbd937452f7E745D", 
"0xDcb980b3d6Bd61a86A8d7Cb9bbd937452f7E745D" ], _id: 
ObjectId('62275a5b1722b740ade011ad') } ]}

Document Schema

const transaction = new mongoose.Schema({
    id: {type: Number, required:true},
    greeterAddress: {type:String, required:true},
    executed: {type:Number, required:true},
    value: {type:String, required:true},
    approved:{type: [String]}
})
const walletInfo = new mongoose.Schema({
    walletAddress: {type: String, required: true},
    networkName: {type: String, required:true},
    minApproval: {type: Number, required:true},
    ownerAddress: {type: [String]},
    greeter: {type: [String]}, 
    transactionList: {type:[transaction]}
})

Executed code which is giving out the error

app.post('/approve_transaction', async(req,res)=>{
    walletAddress = req.query.address
    id =  req.query.id
    greeterAddress =  req.query.greeterAddress
    await walletInfo.updateOne(
        {
            walletAddress:walletAddress,
            'transactionList.id':id,
            'transactionList.greeterAddress':greeterAddress
        },
        {
            $push:{
                'transactionList.approved':walletAddress
            }
        })
    res.sendFile('success')
       
    
})

Document present below

{
"_id" : ObjectId("62275a0f1722b740ade011a9"),
"walletAddress" : "0xDcb980b3d6Bd61a86A8d7Cb9bbd937452f7E745D",
"networkName" : "4",
"minApproval" : 1,
"ownerAddress" : [ 
    "0x6ED8cB56eF8602e138E7e588EA65A5b33f402087", 
    "0x6cb691b71CB057e3C92DBB729580e1A7A2868e1c"
],
"greeter" : [],
"transactionList" : [ 
    {
        "id" : 0,
        "greeterAddress" : "0x0",
        "executed" : 0,
        "value" : "namaste",
        "approved" : [],
        "_id" : ObjectId("62275a5b1722b740ade011ad")
    }
],
"__v" : 0
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Issue solved by replacing transactionList.approved by transactionList.$.approved

about 4 years ago · Juan Pablo Isaza 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