<commit_before>var mongoose = require('mongoose');
var async    = require('async');
var sha1     = require('sha1');
var _        = require('underscore');
var jpgp     = require('../lib/jpgp');
var fs       = require('fs');
var hdc      = require('../../node_modules/hdc');
var Schema   = mongoose.Schema;

var CoinSchema = new Schema({
  id: String,
  owner: String,
  transaction: String,
  created: { type: Date, default: Date.now },
  updated: { type: Date, default: Date.now }
});

CoinSchema.pre('save', function (next) {
  this.updated = Date.now();
  next();
});

CoinSchema.methods = {
};

CoinSchema.statics.findByOwner = function (fingerprint, done) {

  this.find({ owner: fingerprint }).sort({created: -1}).exec(done);
};

CoinSchema.statics.findByCoinID = function (coindID, done) {

  this.find({ id: new RegExp('^'+coindID) }).exec(function (err, coins) {
    if(err || coins.length == 0){
      done('Coin not found');
      return;
    }
    if(coins.length > 1){
      done('More that one coin with ID "'+coindID+'" found');
      return;
    }
    done(null, coins[0]);
  });
};

var Coin = mongoose.model('Coin', CoinSchema);<commit_msg>Fix: conflict with coins whose number > 9<commit_after>var mongoose = require('mongoose');
var async    = require('async');
var sha1     = require('sha1');
var _        = require('underscore');
var jpgp     = require('../lib/jpgp');
var fs       = require('fs');
var hdc      = require('../../node_modules/hdc');
var Schema   = mongoose.Schema;

var CoinSchema = new Schema({
  id: String,
  owner: String,
  transaction: String,
  created: { type: Date, default: Date.now },
  updated: { type: Date, default: Date.now }
});

CoinSchema.pre('save', function (next) {
  this.updated = Date.now();
  next();
});

CoinSchema.methods = {
};

CoinSchema.statics.findByOwner = function (fingerprint, done) {

  this.find({ owner: fingerprint }).sort({created: -1}).exec(done);
};

CoinSchema.statics.findByCoinID = function (coindID, done) {

  this.find({ id: new RegExp('^'+coindID+'-') }).exec(function (err, coins) {
    if(err || coins.length == 0){
      done('Coin not found');
      return;
    }
    if(coins.length > 1){
      done('More that one coin with ID "'+coindID+'" found');
      return;
    }
    done(null, coins[0]);
  });
};

var Coin = mongoose.model('Coin', CoinSchema);
{'fraction_non_alphanumeric': 0.18499573742540495, 'fraction_numerical': 0.005541346973572037, 'mean_word_length': 3.403377110694184, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '6298899', 'n_tokens_mistral': 812, 'n_tokens_neox': 796, 'n_words': 193}