<commit_before>var mongojs = require('mongojs');
var db = mongojs('amitupadhyay', ['col1']);// analogous to ('database name', ['collection1', 'collection2'...]);

var user = {
    username : 'amitupadhyay',
    email : '<EMAIL>',
    password : '<PASSWORD>'
};

db.col1.remove({}, function (err, response) {// empty object says I need to remove all documents in collection
    if (err)
        throw err;
    console.log(response);

    // after the remove is successfully done,
    // this is also called as callback hell
    db.col1.save(user, function (err, data) {
        if (err)
            throw err;
        else
            console.log('Saved successfully', data);
    });
});<commit_msg>cleaner code without involving callbackhell<commit_after>var mongojs = require('mongojs');
var db = mongojs('amitupadhyay', ['col1']);// analogous to ('database name', ['collection1', 'collection2'...]);

var user = {
    username : 'amitupadhyay',
    email : '<EMAIL>',
    password : '<PASSWORD>'
};

function handleRemove(err, response)
{
    if (err)
        throw err;
    console.log(response);

    db.col1.save(u, handleSave);
}

function handleSave(err, u)
{
    if (err)
        throw err;
    console.log('Saved successfully', u);
}


db.col1.remove({}, handleRemove);// empty object means I want to remove all the documents in the collection

/*
 * A more cleaner code not involving callback hell
 * */
{'fraction_non_alphanumeric': 0.14932767162066526, 'fraction_numerical': 0.007077140835102618, 'mean_word_length': 3.1710914454277286, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '132279', 'n_tokens_mistral': 439, 'n_tokens_neox': 434, 'n_words': 134}