Defining the Project Model

For this example, you only need to implement the schema for the words database to store words for the tables example. Listing 29.1 shows the WordSchema model. You should already be familiar with this schema from Chapters 13–16.

Listing 29.1 word_model.js: Defining a schema for the words database


01 var mongoose = require('mongoose'),
02 var Schema = mongoose.Schema;
03 var WordSchema = new Schema({
04   word: {type: String, index: 1, required:true, unique: true},
05   first: {type: String, index: 1},
06   last: String,
07   size: Number,
08   letters: [String],
09   stats: {
10     vowels:Number, consonants:Number},
11   charsets: [{ type: String, chars: [String]}]
12 });
13 mongoose.model('Word', WordSchema);


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.75.43