Created
July 3, 2014 11:34
-
-
Save jlopezr/4be3201392a03ab9725e to your computer and use it in GitHub Desktop.
Two level model for formage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'), | |
Types = mongoose.Schema.Types; | |
var Level2 = { | |
name : { type: String } | |
}; | |
var Level1 = { | |
name : { type: String }, | |
items : [ Level2 ] | |
}; | |
var schema = new mongoose.Schema({ | |
title: { type: String }, | |
items : [ Level1 ] | |
}); | |
schema.methods.toString = function() { | |
return this.title; | |
}; | |
var pages = module.exports = mongoose.model('recipes', schema); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment