<commit_before>/**
 * Created by mosaic101 on 2016/7/14.
 */
const mongoose = require('mongoose');
const Schema = mongoose.Schema;

var BlogSchema  = new Schema({
    //TODO 模拟mysql自增id
    f_id: {type: Number, required: true},
    //title
    title: {type: String, required: true},
    //别名
    slug: {type: String, required: true},
    //文章内容
    markdown: {type: String, required: true},
    //TODO
    html: {type: String, required: false},
    //状态
    state: {type: String, default: 'published'},
    //阅读量
    readCount: {type: Number, default: 0},
    //置顶 0:不置顶 1:置顶
    top: {type: Number, default: 0},
    //meta
    metaTitle: {type: String, required: false},
    //meta
    metaDesc: {type: String, required: false},
    //创建时间
    createdAt: {type: Date, default: Date.now},
    //创建人
    createdBy: {type: String, required: true, ref: 'Users'},
    //修改时间
    updatedAt: {type: Number, default: Date.now},
    //修改人
    updatedBy: {type: String, required: true, ref: 'Users'}
});

module.exports = mongoose.model('Blogs', BlogSchema);

<commit_msg>add incrementId function<commit_after>/**
 * Created by mosaic101 on 2016/7/14.
 */
const mongoose = require('mongoose');
const Schema = mongoose.Schema;

var BlogSchema  = new Schema({
    //自定义序列号 依次递增
    fid: {type: Number, required: true},
    //title
    title: {type: String, required: true},
    //别名
    slug: {type: String, required: true},
    //文章内容
    markdown: {type: String, required: true},
    //TODO
    html: {type: String, required: false},
    //状态
    state: {type: String, default: 'published'},
    //阅读量
    readCount: {type: Number, default: 0},
    //置顶 0:不置顶 1:置顶
    top: {type: Number, default: 0},
    //meta
    metaTitle: {type: String, required: false},
    //meta
    metaDesc: {type: String, required: false},
    //创建时间
    createdAt: {type: Date, default: Date.now},
    //创建人
    createdBy: {type: String, required: true, ref: 'Users'},
    //修改时间
    updatedAt: {type: Number, default: Date.now},
    //修改人
    updatedBy: {type: String, required: true, ref: 'Users'}
});


BlogSchema.methods.incrementId = function(tablename, callback) {
    BlogSchema.findAndModify({"tablename":tablename}, [], {$inc:{'fid':1}}, {new:true, upsert:true}, function(err, result) {
        if (err) return callback(err);
        callback(null, result.fid);
    });
};

module.exports = mongoose.model('Blogs', BlogSchema);


{'fraction_non_alphanumeric': 0.1672893316728933, 'fraction_numerical': 0.012038190120381901, 'mean_word_length': 3.0166666666666666, 'pattern_counts': {'":': 1, '<': 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': '3908127', 'n_tokens_mistral': 873, 'n_tokens_neox': 880, 'n_words': 237}