提问者:小点点

MongoDB禁用模式值


(首先为我糟糕的英语感到抱歉)

const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const date = new Date();


const blogSchema = new Schema({
    header:{
        type : String,
        required : true,
        unique : true
    },
    date: {
        type : Date,
        default : date
        //disabled: true (i need something like this)
    },
    content:{
        type : String,
        required : true
    },
    author:{
        type : String,
        required : true
    }
})

const Blogs = mongoose.model('Bloglar', blogSchema);

module.exports = Blogs;

我将adminbro API与Node.js和MongoDB一起使用。 我必须禁用日期节以保持它与默认值。 如何使用MongoDB实现这一点?


共1个答案

匿名用户

我找到了。

const options = {
resources: [{
    resource:Blogs,
    options: {
        parent: {
            name: "Blog Yazıları"
        },
        properties: {
            date: {
                isVisible: {
                    list: true, show: false, edit: false, filter: true
                }
            },
            content: {
                type: 'richtext'
            }
        }
    },
}],
branding:{
    companyName: "Kişisel Blog"
}

}

我在adminbro页面中通过设置isVisible Object实现了这一点。