Saturday, 10 June 2017

MongoDB Deeply Nested

I am have some difficulties with deeply nested arrays within MongoDB. I am using mongoose and my project consists of micro-services that all currently use the same database collection. Is it possible to use the below example with how deeply nested it is? If so, how would one access the "questionUser" , "questionTitle", or "questionContent". I currently am able to add course and lesson titles. when I am trying to add question data the correct router is getting hit, but it just hangs and times out and all the data going through is null.

I have condensed the data example below. I am working with MEAN Stack. I also am not seeing any errors, it is just hanging. Not sure where or how to start troubleshooting this. I am not against redesigning my db, but would like to keep with nested/embedded structure somehow but would need a little guidance on how i might look to change it. Please let me know if any further info would be needed to ensure this is clear.

Thank you.

Database

{
 "_id": "593bc9fbbc083a8200eb9b36",
  "courseTitle": "Course 101",
  "courseActive": true,
  "lessons": [
    {
      "lessonTitle": "Lesson about widgets",
      "_id": "593bcecc0799cd89a87ce53e",
      "lessonActive": true,
      "questions": [
        {
            "questionUser": "user1",
            "_id" : "dadsfjlkj23o21",
            "questionTitle": "title",
            "questionContent": "stuffff",
            "answers" : [
                {
                    "answerUser": "user2",
                    "_id": "asdfk231191837d",
                    "answerContent": "the answer is simple",
                    "comment": [
                        {
                            "commentUser": "user1",
                            "_id": "asdkjfawow8183",
                            "commentBody": "That makes sense, thanks!"
                        }
                        ]
                }
                ]
        }
        ]
    }
  ]
}



via bemon

No comments:

Post a Comment