{timestamps: true }
If we add this to mongose schema it create CreatedAt & UpdatedAt feild on document create and update Updated At update , updateMany findandudateOne
Referance Link https://mongoosejs.com/docs/timestamps.html
| const mongoose = require("mongoose"); | |
| const Schema = mongoose.Schema; | |
| var aggregatePaginate = require("mongoose-aggregate-paginate-v2"); | |
| const feedbackSchema = Schema({ | |
| user_id: { type: Schema.Types.ObjectId, ref: 'user' }, | |
| profile_id: { type: Schema.Types.ObjectId, ref: 'profile' }, | |
| feedback: { | |
| type: String, | |
| required: true, | |
| }, | |
| is_read: { | |
| type: Boolean, | |
| default: 0, | |
| }, | |
| is_deleted: { | |
| type: Boolean, | |
| default: 0, | |
| }, | |
| }, {timestamps: true }); | |
| feedbackSchema.plugin(aggregatePaginate); | |
| module.exports = feedback = mongoose.model("feedback", feedbackSchema); |
{timestamps: true }
If we add this to mongose schema it create CreatedAt & UpdatedAt feild on document create and update Updated At update , updateMany findandudateOne
Referance Link https://mongoosejs.com/docs/timestamps.html