<commit_before>var mongodb = require('./db');

function User(user) {
  this.name = user.name;
  this.password = <PASSWORD>;
  this.xml = user.xml;
};
module.exports = User;

User.prototype.save = function save(callback) {
  // save to mongodb
  var user = {
    name: this.name,
    password: <PASSWORD>,
    xml:this.xml
  };
  mongodb.open(function(err, db) {
    if (err) {
      return callback(err);
    }
    // read users collection
      // read users collection
    db.collection('counters', function(err, collection) {
      if (err) {
        mongodb.close();
        return callback(err);
      }
      // write to user
      collection.findAndModify({ _id: 'uid' }, [], { $inc: { seq: 1 } }, {}, function(err, res) {
        if (res) {
            db.collection('users', function(err, collection) {
            if (err) {
              mongodb.close();
              return callback(err);
            }
            // ensure names to be unique
            collection.ensureIndex('name', {unique: true},function(err){
              mongodb.close();
              callback(err,null);
            });
            // write to user
            user.uid = res.seq;
            collection.insert(user, {safe: true}, function(err, user) {
              mongodb.close();
              callback(err, user);
            });
          });
        } else {      
          mongodb.close();
          callback(err, null);
        }
      });
    });
  });
};
User.prototype.update = function update(callback) {
  // save to mongodb
  var user = {
    name: this.name,
    password: <PASSWORD>,
    xml:this.xml
  };
  mongodb.open(function(err, db) {
    if (err) {
      return callback(err);
    }
    // read users collection
    db.collection('users', function(err, collection) {
      if (err) {
        mongodb.close();
        return callback(err);
      }
      // update user
      collection.update({name: user.name}, {$set: {xml: user.xml}}, {safe: true}, function(err, user) {
        mongodb.close();
        callback(err, user);
      });
    });
  });
};

User.get = function get(username, callback) {
  mongodb.open(function(err, db) {
    if (err) {
      return callback(err);<commit_msg>Editted Auto Increment Field For UID counter<commit_after>var mongodb = require('./db');

function User(user) {
  this.name = user.name;
  this.password = <PASSWORD>;
  this.xml = user.xml;
  this.uid = user.uid;
};
module.exports = User;

User.prototype.save = function save(callback) {
  // save to mongodb
  var user = {
    name: this.name,
    password: <PASSWORD>,
    xml:this.xml,
    user:this.uid
  };
  mongodb.open(function(err, db) {
    if (err) {
      return callback(err);
    }
    // read users collection
      // read users collection
    db.collection('counters', function(err, collection) {
      if (err) {
        mongodb.close();
        return callback(err);
      }
      // write to user
      collection.findAndModify({ _id: 'uid' }, [], { $inc: { seq: 1 } }, {}, function(err, res) {
        if (res) {
            db.collection('users', function(err, collection) {
            if (err) {
              mongodb.close();
              return callback(err);
            }
            // ensure names to be unique
            collection.ensureIndex('name', {unique: true},function(err){
              mongodb.close();
              callback(err,null);
            });
            // write to user
            user.uid = res.seq;
            collection.insert(user, {safe: true}, function(err, user) {
              mongodb.close();
              callback(err, user);
            });
          });
        } else {      
          mongodb.close();
          callback(err, null);
        }
      });
    });
  });
};
User.prototype.update = function update(callback) {
  // save to mongodb
  var user = {
    name: this.name,
    password: <PASSWORD>,
    xml:this.xml,
    uid:this.uid
  };
  mongodb.open(function(err, db) {
    if (err) {
      return callback(err);
    }
    // read users collection
    db.collection('users', function(err, collection) {
      if (err) {
        mongodb.close();
        return callback(err);
      }
      // update user
      collection.update({name: user.name}, {$set: {xml: user.xml}}, {safe: true}, function(err, user) {
        mongodb.close();
        callback(err, user);
      });
    });
  });
};

User.get = function get(username, callback) {
  mongodb.open(function(err, db) {
    if (err) {
      return callback(err);
{'fraction_non_alphanumeric': 0.15241057542768274, 'fraction_numerical': 0.00044434570095534326, 'mean_word_length': 1.8785166240409208, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 16}, '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': '6133518', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1349, 'n_words': 305}