SoftwareBrothers / adminjs

AdminJS is an admin panel for apps written in node.js
https://adminjs.co
MIT License
8.15k stars 659 forks source link

How to can we remove auto generated fields from the UI #1563

Open Shubham-Kumar-2000 opened 11 months ago

Shubham-Kumar-2000 commented 11 months ago

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

RudrikaJnext commented 11 months ago

@Shubham-Kumar-2000 You can hide them by adding properties in Option section of your resource. resource: organisationusers, options: { properties: { filePath: { isVisible: { filter: false, show: false, list: false } }, createdAt: { isVisible: { filter: false, show: false, edit: true } }, updatedAt: { isVisible: { filter: false, show: false, edit: true } }, } }