title: Best way to structure mongoDB schemas for a Trello-like app using mongoose?
body: <p>Right now i'm thinking of doing it like this:</p>
  
  <p><strong>Board</strong>:</p>
  
  <pre><code>const BoardSchema = new Schema({
      title: {
          type: String,
          required: true,
      },
      admins: [
          {
              type: ObjectId,
              ref: 'User',
              required: true,
          }
      ],
      members: [
          {
              type: ObjectId,
              ref: 'User',
              required: true,
          }
      ],
  }, {
      timestamps: true,
  });
  </code></pre>
  
  <p><strong>List</strong>:</p>
  
  <pre><code>const listSchema = new mongoose.Schema({
      name: {
          type: String,
          required: true
      },
      order: {
          type: Number,
          required: true,
      },
      boardId: {
          type: ObjectId,
          required: true,
          ref: 'Board',
      },
  });
  </code></pre>
  
  <p><strong>Card</strong>:</p>
  
  <pre><code>const cardSchema = new Schema({
      text: {
          type: String,
          required: true,
      },
      members: {
          type: ObjectId,
          ref: 'User',
          required: true,
      },
      listId: {
          type: ObjectId,
          ref: 'User',
          required: true,
      },
      boardId: {
          type: ObjectId,
          ref: 'Board',
          required: true,
      },
      order: {
          type: Number,
          required: true,
      },
  });
  </code></pre>
  
  <p>I'm new to mongoDB/noSQL and a database noob in general, and structuring a database seems to not be a very strict science, as everyone seems to do it differently. From what i've seen the rule of thumb is to keep as much data in one collection as possible, basically the opposite of traditional databases, but not always? So should i instead save everything in the Board collection? </p>
  
  <p>Going forward with this project i want to try to replicate how one would do in a real scenario to learn as much as possible. And i've been googling around to try and find the schema structure for the real trello app but i cannot find it. All i know is that they do use mongoDB and they have a separate Collection for Cards because with the amount of data they handle it wouldn't work otherwise. So i assume they have a separate Collection for Lists (and Boards) aswell.</p>
  
  <p>So my question is if these Schemas would work? And what would be the best way to go about getting all the data (when a user clicks on a board) using the boardId and combining it into a List of Cards?</p>