Last active
March 21, 2021 14:54
-
-
Save loloDawit/0e4c029b006b0c1b65e521ed72778c69 to your computer and use it in GitHub Desktop.
Note Model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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