<commit_before>'use strict';
var mongoose = require('mongoose'),
  Schema = mongoose.Schema;

var MemberSchema = new Schema({
  pre_id: String, // 原来系统中的数据纪录的id
  phone_number: {
    type: String,
    required: true
  },
  baby_name: {
    type: String,
    required: true
  },
  baby_birthday: Date,
  isBoy: Boolean,  // sexual
  card_number: {
    type: String,
    required: true,
    unique: true,
    index: true
  },
  active_time: {
    type: Date,
    default: Date.now
  },
  valid_days: Number,
  level: {  	// 会员类型 0,1,2
    type: Number,
    enum: [0, 1, 2]
  },
  parent_name: String,
  address: String,
  email: {
    type: String,
    match: /.+\@.+\..+/
  } ,
  weixin: String,
  other: String,  // 备注
  head_photo: String // 头像
}, {
  collection: 'member'
});

MemberSchema.statics.findOneByCardNumber = function (card_number, callback) {
    this.findOne({card_number: new RegExp(card_number,'i')}, callback);
};

var MemeberModel = mongoose.model('Member', MemberSchema);<commit_msg>add max_book and locked to the member model , find member by card_number should matched strictly.<commit_after>'use strict';
var mongoose = require('mongoose'),
  Schema = mongoose.Schema;

var MemberSchema = new Schema({
  pre_id: String, // 原来系统中的数据纪录的id
  phone_number: {
    type: String,
    required: true
  },
  baby_name: {
    type: String,
    required: true
  },
  baby_birthday: Date,
  isBoy: Boolean,  // sexual
  card_number: {
    type: String,
    required: true,
    unique: true,
    index: true
  },
  active_time: {
    type: Date,
    default: Date.now
  },
  valid_days: Number,
  level: {  	// 会员类型 0,1,2
    type: Number,
    enum: [0, 1, 2]
  },
  parent_name: String,
  address: String,
  email: {
    type: String,
    match: /.+\@.+\..+/
  } ,
  weixin: String,
  other: String,  // 备注
  max_book: {
    type: Number,
    default: 4
  },
  locked: {
    type: Boolean,
    default: false
  },
  head_photo: String // 头像
}, {
  collection: 'member'
});

MemberSchema.statics.findOneByCardNumber = function (card_number, callback) {
    this.findOne({card_number: card_number}, callback);
};

var MemeberModel = mongoose.model('Member', MemberSchema);
{'fraction_non_alphanumeric': 0.14167812929848694, 'fraction_numerical': 0.005960568546538285, 'mean_word_length': 2.9528985507246377, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5374614', 'n_tokens_mistral': 812, 'n_tokens_neox': 822, 'n_words': 190}