{"size": 881, "ext": "js", "max_stars_repo_path": "server/playground/mongodb-delete.js", "max_stars_repo_name": "Trex010/NodeToDoAPI", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/playground/mongodb-delete.js", "max_issues_repo_name": "Trex010/NodeToDoAPI", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server/playground/mongodb-delete.js", "max_forks_repo_name": "Trex010/NodeToDoAPI", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.5897435897, "max_line_length": 75, "alphanum_fraction": 0.5698070375}
const MongoClient = require('mongodb').MongoClient;

MongoClient.connect('mongodb://localhost:27017/TodoApp', (err, client) =>{
  if(err) {
    return console.log('Unable to connect to MongoDB server');
  }
  console.log('Connect to MongoDB server');
  const db = client.db('TodoApp');

  //deleteMany
  db.collection('TestMongo')
    .deleteMany({
      text: 'Something to do'
    })
    .then((result) => {
      console.log('Delete Log', result);
    });

  //deleteOne
  db.collection('TestMongo')
    .deleteMany({
      text: 'Something to do'
    })
    .then((result) => {
      console.log('Delete Log', result);
    });
    
  //findOneAndDelete
  db.collection('TestMongo')
    .findOneAndDelete({
      text: 'Something to do'
    })
    .then((result) => {
      console.log('Delete Log', result);
    });

  client.close();
});
