Arrays in structs


I have a collection in MongoDB in which there is an array of documents for one value. How can I represent this collection in MongoDB in the form of struct in GO.

You would help us help you if you would not include code as a screenshot but as text.

For example, as a slice of maps from string to string.

type foo struct {
  // ...
  ItemDetails []map[string]string
1 Like

WriteResult({ “nInserted” : 1 })

"_id" : ObjectId(“5a9d154623ee1b17b033abd5”),
“itemname” : “Book”,
“itemtype” : “A”,
“itemdetails” : [
“detail1” : “D1”,
“detail2” : “D2”
“detail3” : “D3”,
“detail4” : “D4”

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.