javascriptnode.jsmongodbmongoosemean-stack

data type to store time with mongoose


I have to make an appointment system for doctors using MEAN stack. in my Schema I've to store the start time and end time of a slot. Mongoose has no data type to store time.What data type should I use to store time?


Solution

  • You can set the timestamps property to true when defining a Schema and mongoose will add a createdAt and updatedAt field for you. Mongoose will also update the updatedAt field for you when you do any update operation.

    var schema = new Schema({
        // ... Schema properties
    }, {
        timestamps: true
    });
    

    http://mongoosejs.com/docs/guide.html#timestamps