title: How to retrieve hashtags from MongoDB Array of Strings?
body: <p>I have saved hashtags as an array of Strings. Saved in MongoDB in the following format:</p>
  
  <pre><code>const postSchema = new Schema {
    name:{type: String},
    tags: {type: [String], required: true}
  });
  </code></pre>
  
  <p>I want to retrieve a list of tags from my database. The following route returns all tags by scanning all posts:</p>
  
  <pre><code>Post.find({}, 'tags').exec(function(err,tags){
      res.send({tags});
  }
  </code></pre>
  
  <p>But that includes a lot of repetition and isn't a clean list. As well as takes a lot of time to load because I have a lot of posts. </p>
  
  <p>Is there a better way to retrieve hashtags? I'm thinking of saving hashtags as a new Schema modal and just referencing them to the post schema. </p>