node.js - mongoDB + mongoose: choosing the right schema for hierarchical data -


I'm new to mongoDB and in a node project I'm using Mongoos to create a schema for my database I understand that in my case I should use embedded data instead of context.

  • Title
  • | | Lesson
  • | | | Content (url in an html file)
  • Coming from a MySQL world, I am trying to understand the NoSQL database concepts and I was wondering how to design a Mongoose schema Will do

    Thx,

    You Nest documents and documents Ares can do a MongoDB document:

      db.books.findOne ();  

    A JSON can return:

      {isbn: "253GHST78F6", Title: "Some Book", Author: "Ernest Hemingway", chapters: [{Title: "Chapter 1", Content: "http://api.com/chapters/1.html"}, {title: "Chapter 2", Content: "http://api.com/chapters/2 However, there are some more things during the modeling of a compilation in MongoDB: 

    1. The model data will be asked as close as possible: Anyone in the MongoDB is not included , therefore, all such data are (formerly linked) a bit Try to keep tha, it is believed that in the future simultaneous inquiries.

    2. Good for nesting queries, but nested updates and search is bad:

      <
    3. Anyone

      Forgotten Keys in Mongodebi

      / Em> Therefore, if you have several copies of a single document nested under different collections, then keep them updated by keeping your zoom Dari is


    Comments