mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-02-20 05:17:05 +01:00
31 lines
635 B
JavaScript
31 lines
635 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); |