Ajout de models et routes pour les QCM
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
var mongoose = require('mongoose');
|
||||
var uniqueValidator = require('mongoose-unique-validator');
|
||||
var slug = require('slug');
|
||||
|
||||
var QCMCategorySchema = new mongoose.Schema({
|
||||
num: number,
|
||||
name: { type: String, lowercase: true, unique: true },
|
||||
questions: []
|
||||
}, {timestamps: true, toJSON: {virtuals: true}});
|
||||
|
||||
QCMCategorySchema.plugin(uniqueValidator, { message: 'is already taken' });
|
||||
|
||||
QCMCategorySchema.methods.toJSONFor = function(){
|
||||
return {
|
||||
num: this.num,
|
||||
name: this.name,
|
||||
questions: this.questions,
|
||||
createdAt: this.createdAt,
|
||||
updatedAt: this.updatedAt
|
||||
};
|
||||
};
|
||||
|
||||
mongoose.model('QCMCategory', QCMCategorySchema);
|
||||
Reference in New Issue
Block a user