mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-05-05 19:27:13 +02:00
29 lines
636 B
JavaScript
29 lines
636 B
JavaScript
/**
|
|
* Module dependencies.
|
|
*/
|
|
var mongoose = require('mongoose'),
|
|
env = process.env.NODE_ENV || 'development',
|
|
config = require('../../config/config')[env],
|
|
Schema = mongoose.Schema;
|
|
|
|
|
|
/**
|
|
* Article Schema
|
|
*/
|
|
var ArticleSchema = new Schema({
|
|
created: {type : Date, default : Date.now},
|
|
title: {type: String, default: '', trim : true},
|
|
content: {type: String, default: '', trim : true},
|
|
user: {type : Schema.ObjectId, ref : 'User'}
|
|
});
|
|
|
|
/**
|
|
* Statics
|
|
*/
|
|
ArticleSchema.statics = {
|
|
load: function (id, cb) {
|
|
this.findOne({ _id : id }).populate('user').exec(cb);
|
|
}
|
|
};
|
|
|
|
mongoose.model('Article', ArticleSchema); |