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'/approve_transaction', async(req,res)=>{
    walletAddress = req.query.address
    id =
    greeterAddress =  req.query.greeterAddress
    await walletInfo.updateOne(

Document present below

"_id" : ObjectId("62275a0f1722b740ade011a9"),
"walletAddress" : "0xDcb980b3d6Bd61a86A8d7Cb9bbd937452f7E745D",
"networkName" : "4",
"minApproval" : 1,
"ownerAddress" : [ 
"greeter" : [],
"transactionList" : [ 
        "id" : 0,
        "greeterAddress" : "0x0",
        "executed" : 0,
        "value" : "namaste",
        "approved" : [],
        "_id" : ObjectId("62275a5b1722b740ade011ad")
"__v" : 0


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x