title: node express mongodb add data to database
body: <p>I need add word to database if that word not exist in my database, if exist show message "word arleady exist, enter another word". Now my code add new word or update if word exist, but i cant to do alert message to show that word arleady exist</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>router.post('/insert', function (req, res, next) {
      if (req.body.title.length == 0) {
          var inputFile = "./k5audios/" + req.body.inputFile;
          var item = {
              title: req.body.inputFile.substring(0, (req.body.inputFile.length - 4)),
              content: inputFile
          }
      } else {
          var item = {
              title: req.body.title.toLowerCase(),
              content: "https://ssl.gstatic.com/dictionary/static/sounds/de/0/" + req.body.title.toLowerCase() + ".mp3"
          }
      }
  
      mongo.connect(url, function (err, db) {
          assert.equal(null, err);
         db.collection('words').update(item,
             {$inc: {score: 1}},
             {upsert: true, safe: false},
             function(err,data){
                 if (err){
                     console.log(err);
                 }else{
                     console.log("score succeded");
                 }
             });
      });
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form action="/insert" method="post"&gt;
                                  &lt;div class="modal-body"&gt;
                                      &lt;div class="form-group"&gt;
                                          &lt;label for="title"&gt;New Word&lt;/label&gt;
                                          &lt;input type="text" class="form-control" id="title" name="title" placeholder="Enter new word"&gt;
                                      &lt;/div&gt;
                                      &lt;div class="form-group"&gt;
                                          &lt;label for="exampleInputFile"&gt;File input&lt;/label&gt;
                                          &lt;input type="file" id="inputFile" name="inputFile"&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  &lt;div class="modal-footer"&gt;
                                      &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;
                                      &lt;button type="submit" class="btn btn-primary"&gt;Save changes&lt;/button&gt;
  
                                  &lt;/div&gt;
  
                              &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><a href="https://i.stack.imgur.com/mZwoc.png" rel="nofollow noreferrer">enter image description here</a></p>