Answers for "setting mongoose timestamp option"

4

timestamps in mongoose

const userSchema = mongoose.Schema(
  {
    email: String,
  },
  { timestamps: true }
);
Posted by: Guest on May-17-2021
0

custom timestamp name mongoose

const mongoose = require('mongoose');  
const { Schema } = mongoose;
    
const schemaOptions = {
  timestamps: { createdAt: 'created_at', updatedAt: 'updated_at' },
};

const mySchema = new Schema({ name: String }, schemaOptions);
Posted by: Guest on August-07-2021

Code answers related to "setting mongoose timestamp option"

Browse Popular Code Answers by Language