Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mogoose schema to add json as a property

// Initial requires
var mongoose = require('mongoose'),
    Schema = mongoose.Schema;

// A generic answer sub-schema
var answerSchema = new Schema({
    answer: String,
    correct: Boolean
});

// A generic Question schema
var  questionSchema = new Schema({
    text: String,
    answers: [answerSchema]
});

exports.Question = mongoose.model( 'Question', questionSchema );
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #mogoose #schema #add #json #property
ADD COMMENT
Topic
Name
8+5 =