Skip to content

Instantly share code, notes, and snippets.

@loloDawit
Last active March 21, 2021 14:54
Show Gist options
  • Save loloDawit/0e4c029b006b0c1b65e521ed72778c69 to your computer and use it in GitHub Desktop.
Save loloDawit/0e4c029b006b0c1b65e521ed72778c69 to your computer and use it in GitHub Desktop.
Note Model
const mongoose = require('mongoose');
const validator = require('validator');
const NoteSchema = new mongoose.Schema(
{
title: {
type: String,
required: true,
validator: {
validator(title) {
return validator.isAlphanumeric(title);
},
},
},
description: {
type: String,
required: true,
validator: {
validator(description) {
return validator.isAlphanumeric(description);
},
},
},
reminder: {
type: Boolean,
require: false,
default: false,
},
status: {
type: String,
enum: ['completed', 'new'],
default: 'new',
},
category: {
type: String,
enum: ['work', 'todos', 'technology', 'personal'],
default: 'todos',
},
},
{
timestamps: true,
}
);
module.exports = mongoose.model('Note', NoteSchema);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment