Home > Net >  How to write an array containing dictionaries to mongodb using mongoose
How to write an array containing dictionaries to mongodb using mongoose

Time:09-19

I have my data structured as [{type: "advanced", price: 5000}]. The schema type is set to type: []. When I query the data in my browser (using react) I get an array but the objects like ['[object Object],[object Object]']. How can I save this data and retrieve it correctly

CodePudding user response:

Try this as the schema:

type:[{type:String , price:Number }]

CodePudding user response:

I have found the solution, JSON.stringify(myobject) when appending it to the form before sending

  • Related