Skip to content

Instantly share code, notes, and snippets.

@jlopezr
Created July 3, 2014 11:34
Show Gist options
  • Save jlopezr/4be3201392a03ab9725e to your computer and use it in GitHub Desktop.
Save jlopezr/4be3201392a03ab9725e to your computer and use it in GitHub Desktop.
Two level model for formage
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