title: How to define an object in NodeJS schema?
body: <p>I currently have a schema like this:</p>
  <pre><code>const postSchema = mongoose.Schema({
      title: String,
      message: String,
      name: String,
      creator: String,
      tags: [String], 
      selectedFile: String,
      likes: { type: [String], default: [] }, 
      createdAt: {
          type: Date,
          default: new Date(),
      },
  })  
  </code></pre>
  <p>One of the problem that I anticipate is that as the number of users grow, searching the likes array will become inefficient. Is there a way to store the likes array instead as an Object (key would be userId and value could be true) so that finding someone in the Object would become more efficient.</p>
  <p>I am also open to hearing any other ideas that you might have.</p>
  <p>Thanks!</p>