1
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?

  • 1
    While the menu will probably not go that deep, just for the record: the maximum nesting level in MongoDB is 100. – mnemosyn Dec 03 '14 at 13:59
  • 1
    You don't want an arbitrarily nested schema. Read over the [Modeling Tree Structures](http://docs.mongodb.org/manual/tutorial/model-tree-structures/) page from the manual for ideas that might fit your use case. – wdberkeley Dec 03 '14 at 15:44
  • 1
    @mnemosyn That's fine. The menu really WILL never go that deep unless some maniac with a lot of free time gets to making something like that. But I still need this functionality. – BadgerBadgerBadgerBadger Dec 04 '14 at 05:39

0 Answers0