Skip to content

Instantly share code, notes, and snippets.

@funador
Created January 20, 2019 19:11
Show Gist options
  • Select an option

  • Save funador/50a5e9ad2974f48cc8d4e86b87132593 to your computer and use it in GitHub Desktop.

Select an option

Save funador/50a5e9ad2974f48cc8d4e86b87132593 to your computer and use it in GitHub Desktop.
const mongoose = require('mongoose')
mongoose.Promise = global.Promise
const TodoSchema = new mongoose.Schema({
text: {
type: String,
required: 'please provide some text for your todo'
},
done: {
type: String,
default: ''
}
})
TodoSchema.set('toObject', {
virtuals: true,
transform: function(doc, ret) {
delete ret._id;
}
})
module.exports = mongoose.model('Todo', TodoSchema)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment