简体   繁体   中英

How to write an array containing dictionaries to mongodb using mongoose

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

Try this as the schema:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM