In the following example we define template
attribute to be of type String
with values defined in the enum
array:
const noteSchema = new Schema({
title: {type:String, required: true},
type: {type:String, required: true, default: 'note'},
content: String,
reference: String,
tags: [String],
template: {type:String, enum: ['note', 'checklist']},
userId: {type: String, ref:'User'},
__v: { type: Number, select: false}
},
{
timestamps: true
});
Shared with β€οΈ from Codever. Use π copy to mine functionality to add it to your personal snippets collection.
Codever is open source on Githubβπ
Top comments (0)