SoftwareBrothers / adminjs-mongoose

Mongoose adapter for AdminJS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to can we remove auto generated fields from the UI

Shubham-Kumar-2000 opened this issue · comments

Suppose there is following collection :

const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const imageSchema = new Schema(
    {
        key: { type: String },
        filePath: { type: String, default: '' }
    },
    { timestamps: true }
);
imageSchema.pre('save', function (next) {
    const data = this;
    data.filePath = 'abc.com' + data.key;
    return next();
});

const Image = mongoose.model('Images', imageSchema);
module.exports = Image;

As you can see her fields like filePath, createdAt and updatedAt are auto generated field and shouldn't come in UI