{"size": 938, "ext": "js", "max_stars_repo_path": "packages/custom/trainer/server/models/paper.js", "max_stars_repo_name": "shouliang/hapihu", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/custom/trainer/server/models/paper.js", "max_issues_repo_name": "shouliang/hapihu", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/custom/trainer/server/models/paper.js", "max_forks_repo_name": "shouliang/hapihu", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.9574468085, "max_line_length": 87, "alphanum_fraction": 0.539445629}
/**
 * Created by shouliang on 2016/11/4.
 */
'use strict';

var mongoose = require('mongoose');
var Schema = mongoose.Schema;

var PaperSchema = new Schema({
    created: {
        type: Date,
        default: Date.now()
    },
    updated: {
        type: Date,
        default: Date.now()
    },
    user: {
        type: Schema.ObjectId,
        ref: 'User'
    },
    title: {
        type: String
    },
    topics: [{
        type: Schema.ObjectId,
        ref: 'Topic'
    }],
    delFlag: {
        type: Number,  // 0:undeleted  1:deleted
        default: 0
    },
    property: {
        type: String, // private or public
        default: 'public'
    }
});

PaperSchema.statics.load = function (id, cb) {
    this.findOne({_id: id})
        .populate('user', 'name username')
        .populate('topics','questionId difficult questionOptions stem answer analysis')
        .exec(cb);
};

mongoose.model('Paper', PaperSchema);
