How can I have infinitely nested Schemas in Mongoose?

时间秒杀一切 提交于 2019-12-24 11:23:43

问题


var SomeSchema = new Schema({
    createdAt: {
        type: Date
    },
    updatedAt: {
        type: Date
    },
    title: {
        type: String,
        required: true
    },
    items: [{
        title: {
            type: String
        },
        children: {}
    }]
}, {collection : 'SomeCollection'});

The children object is essentially another array of item objects, which can further have nested children. So this is for a menu system with inifnite nesting of the same Schema. How do I define it?

来源:https://stackoverflow.com/questions/27268091/how-can-i-have-infinitely-nested-schemas-in-mongoose

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!