var mongoose = require('mongoose'); var QcmChoiceSchema = new mongoose.Schema({ index: String, libelle: String, correct: Boolean }, {timestamps: true, toJSON: {virtuals: true}}); QcmChoiceSchema.methods.toJSONFor = function() { return { index: this.index, libelle: this.libelle, correct: this.correct }; }; mongoose.model('QcmChoice', QcmChoiceSchema);