mongoose schema timestamps true code example
Example: timestamps true mongoose
const userSchema = mongoose.Schema(
{
email: String,
},
{ timestamps: true }
);
const User = mongoose.model("User", userSchema);
const doc = await User.create({ email: "[email protected]" });
doc.createdAt; // 2020-07-06T20:36:59.414Z
doc.updatedAt; // 2020-07-06T20:36:59.414Z
doc.createdAt instanceof Date; // true