summaryrefslogtreecommitdiff
path: root/server/lib/schemas/Documentation.js
blob: 482f6099c5e3929d81df51301601131a1a4b783e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* jshint node: true */

var mongoose = require('mongoose'),
	uniqueValidator = require('mongoose-unique-validator'),
	_ = require('lodash'),
	util = require('../util');

var DocumentationSchema = new mongoose.Schema({
	name: {
		type: String,
		required: true,
		unique: true,
		validate: [function (val){
			val = util.slugify(val || this.displayName || "")
			if (! val.length) return false
			if (val == "new") return false
			return true
		},"{PATH} name is required"]
	},
	displayName: {
		type: String,
	},
	body: {
		type: String,
		default: ""
	},
	created_at: { type: Date },
	updated_at: { type: Date },
});

DocumentationSchema.plugin(uniqueValidator, { message: '{PATH} is already in use.' })

module.exports = exports = mongoose.model('documentation', DocumentationSchema)
exports.schema = DocumentationSchema;