forked from bro-students/multy-stub
24 lines
504 B
JavaScript
24 lines
504 B
JavaScript
const { Schema, model } = require('mongoose')
|
|
|
|
const { TODO_ITEM_MODEL_NAME } = require('../../const')
|
|
|
|
const schema = new Schema({
|
|
title: String,
|
|
done: { type: Boolean, default: false },
|
|
closed: Date,
|
|
created: {
|
|
type: Date, default: () => new Date().toISOString(),
|
|
},
|
|
})
|
|
|
|
schema.set('toJSON', {
|
|
virtuals: true,
|
|
versionKey: false,
|
|
})
|
|
|
|
schema.virtual('id').get(function () {
|
|
return this._id.toHexString()
|
|
})
|
|
|
|
exports.ItemModel = model(TODO_ITEM_MODEL_NAME, schema)
|