June 2014
Intermediate to advanced
696 pages
38h 52m
English
Listing 16.2 implements a schema on the word_stats collection defined in Chapter 15, “Accessing MongoDB Documents from Node.js.” This schema will be used in other examples in this chapter, so it is exported in the final line of Listing 16.2. Notice that the word and first fields have an index assigned to them and that the word field is both unique and required.
For the stats subdocument, the document is defined as normal but with types specified in lines 9–11. Also notice that for the charsets field, which is an array of subdocuments, the syntax defines an array and defines the single subdocument type for the model. Lines 13–15 implement a startsWith() method that is available on Document objects in ...
Read now
Unlock full access