2013-12-25 16:36:33 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
2013-07-09 20:40:39 +03:00
|
|
|
/**
|
2016-01-07 22:18:36 +01:00
|
|
|
* Module dependencies
|
2013-07-09 20:40:39 +03:00
|
|
|
*/
|
2013-08-16 15:23:09 -04:00
|
|
|
var mongoose = require('mongoose'),
|
2015-07-25 16:53:11 -04:00
|
|
|
Schema = mongoose.Schema;
|
2013-08-16 15:23:09 -04:00
|
|
|
|
2013-07-09 20:40:39 +03:00
|
|
|
/**
|
|
|
|
|
* Article Schema
|
|
|
|
|
*/
|
|
|
|
|
var ArticleSchema = new Schema({
|
2015-07-25 16:53:11 -04:00
|
|
|
created: {
|
|
|
|
|
type: Date,
|
|
|
|
|
default: Date.now
|
|
|
|
|
},
|
|
|
|
|
title: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '',
|
|
|
|
|
trim: true,
|
|
|
|
|
required: 'Title cannot be blank'
|
|
|
|
|
},
|
|
|
|
|
content: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '',
|
|
|
|
|
trim: true
|
|
|
|
|
},
|
|
|
|
|
user: {
|
|
|
|
|
type: Schema.ObjectId,
|
|
|
|
|
ref: 'User'
|
2017-03-25 16:03:41 +08:00
|
|
|
},
|
|
|
|
|
test: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'def'
|
2015-07-25 16:53:11 -04:00
|
|
|
}
|
2013-07-09 20:40:39 +03:00
|
|
|
});
|
|
|
|
|
|
2017-03-25 16:03:41 +08:00
|
|
|
ArticleSchema.index({user: -1, created: -1});
|
|
|
|
|
|
2015-02-16 21:35:33 +01:00
|
|
|
mongoose.model('Article', ArticleSchema);
|