├── .gitignore ├── .npmignore ├── .travis.yml ├── CNAME ├── CONTRIBUTING.md ├── History.md ├── Makefile ├── README.md ├── benchmarks ├── benchjs │ ├── casting.js │ ├── delete.js │ ├── insert.js │ ├── multiop.js │ ├── population.js │ ├── read.js │ └── update.js ├── bigboard.json ├── clone.js ├── create.js ├── index.js ├── mem.js ├── populate.js └── populationHeavyLoad.js ├── contRun.sh ├── docs ├── 2.7.x │ ├── announcement.html │ ├── docs │ │ ├── api.html │ │ ├── defaults.html │ │ ├── embedded-documents.html │ │ ├── errors.html │ │ ├── finding-documents.html │ │ ├── getters-setters.html │ │ ├── indexes.html │ │ ├── methods-statics.html │ │ ├── middleware.html │ │ ├── migration-1x-2x.html │ │ ├── model-definition.html │ │ ├── plugins.html │ │ ├── populate.html │ │ ├── query.html │ │ ├── querystream.html │ │ ├── schema-options.html │ │ ├── schematypes.html │ │ ├── style │ │ │ ├── foot.html │ │ │ ├── head.html │ │ │ └── style.css │ │ ├── updating-documents.html │ │ ├── validation.html │ │ └── virtuals.html │ ├── images │ │ ├── bg.png │ │ ├── groups.png │ │ ├── logo.png │ │ └── pattern.png │ ├── index.html │ └── template.html ├── 2.8.x │ ├── announcement.html │ ├── docs │ │ ├── api.html │ │ ├── defaults.html │ │ ├── embedded-documents.html │ │ ├── errors.html │ │ ├── finding-documents.html │ │ ├── getters-setters.html │ │ ├── indexes.html │ │ ├── methods-statics.html │ │ ├── middleware.html │ │ ├── migration-1x-2x.html │ │ ├── model-definition.html │ │ ├── plugins.html │ │ ├── populate.html │ │ ├── query.html │ │ ├── querystream.html │ │ ├── schema-options.html │ │ ├── schematypes.html │ │ ├── style │ │ │ ├── foot.html │ │ │ ├── head.html │ │ │ └── style.css │ │ ├── updating-documents.html │ │ ├── validation.html │ │ └── virtuals.html │ ├── images │ │ ├── bg.png │ │ ├── groups.png │ │ ├── logo.png │ │ └── pattern.png │ ├── index.html │ └── template.html ├── 3.0.x │ ├── docs │ │ ├── api.html │ │ ├── api.jade │ │ ├── contributing.html │ │ ├── contributing.jade │ │ ├── css │ │ │ ├── default.css │ │ │ └── guide.css │ │ ├── documents.html │ │ ├── documents.jade │ │ ├── faq.html │ │ ├── faq.jade │ │ ├── guide.html │ │ ├── guide.jade │ │ ├── helpers │ │ │ ├── filters.js │ │ │ ├── highlight.js │ │ │ ├── href.js │ │ │ ├── klass.js │ │ │ └── linktype.js │ │ ├── images │ │ │ ├── apps │ │ │ │ ├── grab │ │ │ │ └── urls │ │ │ └── square_bg.png │ │ ├── includes │ │ │ ├── googleanalytics.jade │ │ │ └── nav.jade │ │ ├── index.html │ │ ├── index.jade │ │ ├── js │ │ │ └── zepto.min.js │ │ ├── layout.jade │ │ ├── middleware.html │ │ ├── middleware.jade │ │ ├── migration.html │ │ ├── migration.jade │ │ ├── models.html │ │ ├── models.jade │ │ ├── plugins.html │ │ ├── plugins.jade │ │ ├── populate.html │ │ ├── populate.jade │ │ ├── prior.html │ │ ├── prior.jade │ │ ├── queries.html │ │ ├── queries.jade │ │ ├── releases │ │ ├── schematypes.html │ │ ├── schematypes.jade │ │ ├── source │ │ │ ├── _docs │ │ │ ├── api.js │ │ │ ├── home.js │ │ │ ├── index.js │ │ │ └── prior.js │ │ ├── subdocs.html │ │ ├── subdocs.jade │ │ ├── validation.html │ │ └── validation.jade │ ├── index.html │ └── static.js ├── 3.1.x │ ├── docs │ │ ├── api.html │ │ ├── api.jade │ │ ├── contributing.html │ │ ├── contributing.jade │ │ ├── css │ │ │ ├── default.css │ │ │ └── guide.css │ │ ├── documents.html │ │ ├── documents.jade │ │ ├── faq.html │ │ ├── faq.jade │ │ ├── guide.html │ │ ├── guide.jade │ │ ├── helpers │ │ │ ├── filters.js │ │ │ ├── highlight.js │ │ │ ├── href.js │ │ │ ├── klass.js │ │ │ └── linktype.js │ │ ├── images │ │ │ ├── apps │ │ │ │ ├── grab │ │ │ │ └── urls │ │ │ └── square_bg.png │ │ ├── includes │ │ │ ├── googleanalytics.jade │ │ │ └── nav.jade │ │ ├── index.html │ │ ├── index.jade │ │ ├── js │ │ │ └── zepto.min.js │ │ ├── layout.jade │ │ ├── middleware.html │ │ ├── middleware.jade │ │ ├── migration.html │ │ ├── migration.jade │ │ ├── models.html │ │ ├── models.jade │ │ ├── plugins.html │ │ ├── plugins.jade │ │ ├── populate.html │ │ ├── populate.jade │ │ ├── prior.html │ │ ├── prior.jade │ │ ├── queries.html │ │ ├── queries.jade │ │ ├── releases │ │ ├── schematypes.html │ │ ├── schematypes.jade │ │ ├── source │ │ │ ├── _docs │ │ │ ├── api.js │ │ │ ├── home.js │ │ │ ├── index.js │ │ │ └── prior.js │ │ ├── subdocs.html │ │ ├── subdocs.jade │ │ ├── validation.html │ │ └── validation.jade │ ├── index.html │ └── static.js ├── 3.2.x │ ├── docs │ │ ├── api.html │ │ ├── api.jade │ │ ├── connections.html │ │ ├── connections.jade │ │ ├── contributing.html │ │ ├── contributing.jade │ │ ├── css │ │ │ ├── default.css │ │ │ ├── guide.css │ │ │ └── style.css │ │ ├── documents.html │ │ ├── documents.jade │ │ ├── faq.html │ │ ├── faq.jade │ │ ├── guide.html │ │ ├── guide.jade │ │ ├── helpers │ │ │ ├── filters.js │ │ │ ├── highlight.js │ │ │ ├── href.js │ │ │ ├── klass.js │ │ │ └── linktype.js │ │ ├── images │ │ │ ├── apps │ │ │ │ ├── attictv.png │ │ │ │ ├── bozuko.png │ │ │ │ ├── calllist.png │ │ │ │ ├── cldfy.png │ │ │ │ ├── clickdummy.png │ │ │ │ ├── cyborgvision.png │ │ │ │ ├── furbabyrescue.png │ │ │ │ ├── geeklist.png │ │ │ │ ├── grab │ │ │ │ ├── growthegamegolf.png │ │ │ │ ├── kyyti.png │ │ │ │ ├── learnboost.png │ │ │ │ ├── linkr.png │ │ │ │ ├── lists.png │ │ │ │ ├── localresponse.png │ │ │ │ ├── nextdays.png │ │ │ │ ├── nimblequiz.png │ │ │ │ ├── nuorder.png │ │ │ │ ├── scottyapp.png │ │ │ │ ├── seelio.png │ │ │ │ ├── selectvids.png │ │ │ │ ├── sharelatex.png │ │ │ │ ├── shoejitsu.png │ │ │ │ ├── skim.png │ │ │ │ ├── stachify.png │ │ │ │ ├── storify.png │ │ │ │ ├── todaylaunch.png │ │ │ │ ├── treinosmart.png │ │ │ │ ├── upcload.png │ │ │ │ ├── urls │ │ │ │ └── wavo.png │ │ │ └── square_bg.png │ │ ├── includes │ │ │ ├── googleanalytics.jade │ │ │ └── nav.jade │ │ ├── index.html │ │ ├── index.jade │ │ ├── js │ │ │ └── zepto.min.js │ │ ├── layout.jade │ │ ├── middleware.html │ │ ├── middleware.jade │ │ ├── migration.html │ │ ├── migration.jade │ │ ├── models.html │ │ ├── models.jade │ │ ├── plugins.html │ │ ├── plugins.jade │ │ ├── populate.html │ │ ├── populate.jade │ │ ├── prior.html │ │ ├── prior.jade │ │ ├── queries.html │ │ ├── queries.jade │ │ ├── releases │ │ ├── schematypes.html │ │ ├── schematypes.jade │ │ ├── source │ │ │ ├── _docs │ │ │ ├── api.js │ │ │ ├── home.js │ │ │ ├── index.js │ │ │ └── prior.js │ │ ├── subdocs.html │ │ ├── subdocs.jade │ │ ├── validation.html │ │ └── validation.jade │ ├── index.html │ └── static.js ├── 3.3.x │ ├── docs │ │ ├── api.html │ │ ├── api.jade │ │ ├── connections.html │ │ ├── connections.jade │ │ ├── contributing.html │ │ ├── contributing.jade │ │ ├── css │ │ │ ├── default.css │ │ │ ├── guide.css │ │ │ └── style.css │ │ ├── documents.html │ │ ├── documents.jade │ │ ├── faq.html │ │ ├── faq.jade │ │ ├── guide.html │ │ ├── guide.jade │ │ ├── helpers │ │ │ ├── filters.js │ │ │ ├── highlight.js │ │ │ ├── href.js │ │ │ ├── klass.js │ │ │ └── linktype.js │ │ ├── images │ │ │ ├── apps │ │ │ │ ├── attictv.png │ │ │ │ ├── bozuko.png │ │ │ │ ├── calllist.png │ │ │ │ ├── cldfy.png │ │ │ │ ├── clickdummy.png │ │ │ │ ├── cyborgvision.png │ │ │ │ ├── dashku.png │ │ │ │ ├── firstimpression.png │ │ │ │ ├── furbabyrescue.png │ │ │ │ ├── geeklist.png │ │ │ │ ├── grab │ │ │ │ ├── growthegamegolf.png │ │ │ │ ├── h_bozuko.jpg │ │ │ │ ├── h_geeklist.png │ │ │ │ ├── h_learnboost.png │ │ │ │ ├── h_mcds.png │ │ │ │ ├── h_shoejitsu.png │ │ │ │ ├── h_storify.jpg │ │ │ │ ├── kyyti.png │ │ │ │ ├── learnboost.png │ │ │ │ ├── linkr.png │ │ │ │ ├── lists.png │ │ │ │ ├── localresponse.png │ │ │ │ ├── mcdonalds.png │ │ │ │ ├── muffle.png │ │ │ │ ├── nextdays.png │ │ │ │ ├── nimblequiz.png │ │ │ │ ├── nuorder.png │ │ │ │ ├── scottyapp.png │ │ │ │ ├── seelio.png │ │ │ │ ├── selectvids.png │ │ │ │ ├── sharelatex.png │ │ │ │ ├── shoejitsu.png │ │ │ │ ├── skim.png │ │ │ │ ├── squadsheet.png │ │ │ │ ├── stachify.png │ │ │ │ ├── storify.png │ │ │ │ ├── todaylaunch.png │ │ │ │ ├── treinosmart.png │ │ │ │ ├── upcload.png │ │ │ │ ├── urls │ │ │ │ ├── veriwalk.png │ │ │ │ ├── wavo.png │ │ │ │ └── zootify.png │ │ │ └── square_bg.png │ │ ├── includes │ │ │ ├── googleanalytics.jade │ │ │ └── nav.jade │ │ ├── index.html │ │ ├── index.jade │ │ ├── js │ │ │ ├── cookies.min.js │ │ │ └── zepto.min.js │ │ ├── layout.jade │ │ ├── middleware.html │ │ ├── middleware.jade │ │ ├── migration.html │ │ ├── migration.jade │ │ ├── models.html │ │ ├── models.jade │ │ ├── plugins.html │ │ ├── plugins.jade │ │ ├── populate.html │ │ ├── populate.jade │ │ ├── prior.html │ │ ├── prior.jade │ │ ├── production.html │ │ ├── production.jade │ │ ├── queries.html │ │ ├── queries.jade │ │ ├── releases │ │ ├── schematypes.html │ │ ├── schematypes.jade │ │ ├── source │ │ │ ├── _docs │ │ │ ├── api.js │ │ │ ├── home.js │ │ │ ├── index.js │ │ │ ├── prior.js │ │ │ └── production.js │ │ ├── subdocs.html │ │ ├── subdocs.jade │ │ ├── validation.html │ │ ├── validation.jade │ │ └── website.js │ ├── index.html │ └── static.js ├── 3.4.x │ ├── docs │ │ ├── api.html │ │ ├── connections.html │ │ ├── contributing.html │ │ ├── css │ │ │ ├── default.css │ │ │ ├── guide.css │ │ │ └── style.css │ │ ├── documents.html │ │ ├── faq.html │ │ ├── guide.html │ │ ├── helpers │ │ │ ├── filters.js │ │ │ ├── highlight.js │ │ │ ├── href.js │ │ │ ├── klass.js │ │ │ └── linktype.js │ │ ├── images │ │ │ ├── apps │ │ │ │ ├── attictv.png │ │ │ │ ├── bozuko.png │ │ │ │ ├── calllist.png │ │ │ │ ├── cldfy.png │ │ │ │ ├── clickdummy.png │ │ │ │ ├── cyborgvision.png │ │ │ │ ├── dashku.png │ │ │ │ ├── firstimpression.png │ │ │ │ ├── furbabyrescue.png │ │ │ │ ├── geeklist.png │ │ │ │ ├── grab │ │ │ │ ├── growthegamegolf.png │ │ │ │ ├── h_bozuko.jpg │ │ │ │ ├── h_geeklist.png │ │ │ │ ├── h_learnboost.png │ │ │ │ ├── h_mcds.png │ │ │ │ ├── h_shoejitsu.png │ │ │ │ ├── h_storify.jpg │ │ │ │ ├── kyyti.png │ │ │ │ ├── learnboost.png │ │ │ │ ├── linkr.png │ │ │ │ ├── lists.png │ │ │ │ ├── localresponse.png │ │ │ │ ├── mcdonalds.png │ │ │ │ ├── muffle.png │ │ │ │ ├── nextdays.png │ │ │ │ ├── nimblequiz.png │ │ │ │ ├── nuorder.png │ │ │ │ ├── scottyapp.png │ │ │ │ ├── seelio.png │ │ │ │ ├── selectvids.png │ │ │ │ ├── sharelatex.png │ │ │ │ ├── shoejitsu.png │ │ │ │ ├── skim.png │ │ │ │ ├── squadsheet.png │ │ │ │ ├── stachify.png │ │ │ │ ├── storify.png │ │ │ │ ├── todaylaunch.png │ │ │ │ ├── treinosmart.png │ │ │ │ ├── upcload.png │ │ │ │ ├── urls │ │ │ │ ├── veriwalk.png │ │ │ │ ├── wavo.png │ │ │ │ └── zootify.png │ │ │ └── square_bg.png │ │ ├── includes │ │ │ ├── googleanalytics.jade │ │ │ └── nav.jade │ │ ├── index.html │ │ ├── js │ │ │ ├── cookies.min.js │ │ │ └── zepto.min.js │ │ ├── middleware.html │ │ ├── migration.html │ │ ├── models.html │ │ ├── plugins.html │ │ ├── populate.html │ │ ├── prior.html │ │ ├── production.html │ │ ├── queries.html │ │ ├── releases │ │ ├── schematypes.html │ │ ├── source │ │ │ ├── _docs │ │ │ ├── api.js │ │ │ ├── home.js │ │ │ ├── index.js │ │ │ ├── prior.js │ │ │ └── production.js │ │ ├── subdocs.html │ │ ├── validation.html │ │ └── website.js │ ├── index.html │ └── static.js ├── 3.5.x │ ├── docs │ │ ├── api.html │ │ ├── connections.html │ │ ├── contributing.html │ │ ├── css │ │ │ ├── api.css │ │ │ ├── default.css │ │ │ ├── guide.css │ │ │ └── style.css │ │ ├── documents.html │ │ ├── faq.html │ │ ├── guide.html │ │ ├── helpers │ │ │ ├── filters.js │ │ │ ├── highlight.js │ │ │ ├── href.js │ │ │ ├── klass.js │ │ │ └── linktype.js │ │ ├── images │ │ │ ├── apps │ │ │ │ ├── attictv.png │ │ │ │ ├── bozuko.png │ │ │ │ ├── calllist.png │ │ │ │ ├── cldfy.png │ │ │ │ ├── clickdummy.png │ │ │ │ ├── cyborgvision.png │ │ │ │ ├── dashku.png │ │ │ │ ├── firstimpression.png │ │ │ │ ├── furbabyrescue.png │ │ │ │ ├── geeklist.png │ │ │ │ ├── grab │ │ │ │ ├── growthegamegolf.png │ │ │ │ ├── h_bozuko.jpg │ │ │ │ ├── h_geeklist.png │ │ │ │ ├── h_learnboost.png │ │ │ │ ├── h_mcds.png │ │ │ │ ├── h_shoejitsu.png │ │ │ │ ├── h_storify.jpg │ │ │ │ ├── knack.png │ │ │ │ ├── kyyti.png │ │ │ │ ├── learnboost.png │ │ │ │ ├── linkr.png │ │ │ │ ├── lists.png │ │ │ │ ├── localresponse.png │ │ │ │ ├── mcdonalds.png │ │ │ │ ├── moveline.png │ │ │ │ ├── muffle.png │ │ │ │ ├── mybrickbuilds.png │ │ │ │ ├── nextdays.png │ │ │ │ ├── nimblequiz.png │ │ │ │ ├── nuorder.png │ │ │ │ ├── panemerkille.png │ │ │ │ ├── pictorious.png │ │ │ │ ├── scottyapp.png │ │ │ │ ├── seelio.png │ │ │ │ ├── selectvids.png │ │ │ │ ├── sharelatex.png │ │ │ │ ├── shoejitsu.png │ │ │ │ ├── skim.png │ │ │ │ ├── squadsheet.png │ │ │ │ ├── stachify.png │ │ │ │ ├── storify.png │ │ │ │ ├── todaylaunch.png │ │ │ │ ├── treinosmart.png │ │ │ │ ├── upcload.png │ │ │ │ ├── urls │ │ │ │ ├── veriwalk.png │ │ │ │ ├── wavo.png │ │ │ │ └── zootify.png │ │ │ └── square_bg.png │ │ ├── includes │ │ │ ├── googleanalytics.jade │ │ │ └── nav.jade │ │ ├── index.html │ │ ├── js │ │ │ ├── cookies.min.js │ │ │ └── zepto.min.js │ │ ├── middleware.html │ │ ├── migration.html │ │ ├── models.html │ │ ├── plugins.html │ │ ├── populate.html │ │ ├── prior.html │ │ ├── production.html │ │ ├── queries.html │ │ ├── schematypes.html │ │ ├── source │ │ │ ├── _docs │ │ │ ├── api.js │ │ │ ├── home.js │ │ │ ├── index.js │ │ │ ├── prior.js │ │ │ └── production.js │ │ ├── subdocs.html │ │ └── validation.html │ ├── index.html │ └── static.js ├── api.html ├── api.jade ├── connections.jade ├── contributing.html ├── contributing.jade ├── css │ ├── api.css │ ├── default.css │ ├── guide.css │ └── style.css ├── documents.html ├── documents.jade ├── faq.html ├── faq.jade ├── guide.html ├── guide.jade ├── helpers │ ├── filters.js │ ├── highlight.js │ ├── href.js │ ├── klass.js │ └── linktype.js ├── images │ ├── apps │ │ ├── attictv.png │ │ ├── bozuko.png │ │ ├── calllist.png │ │ ├── cldfy.png │ │ ├── clickdummy.png │ │ ├── cyborgvision.png │ │ ├── dashku.png │ │ ├── firstimpression.png │ │ ├── furbabyrescue.png │ │ ├── geeklist.png │ │ ├── grab │ │ ├── growthegamegolf.png │ │ ├── h_bozuko.jpg │ │ ├── h_geeklist.png │ │ ├── h_learnboost.png │ │ ├── h_mcds.png │ │ ├── h_shoejitsu.png │ │ ├── h_storify.jpg │ │ ├── knack.png │ │ ├── kyyti.png │ │ ├── learnboost.png │ │ ├── linkr.png │ │ ├── lists.png │ │ ├── localresponse.png │ │ ├── mcdonalds.png │ │ ├── moveline.png │ │ ├── muffle.png │ │ ├── mybrickbuilds.png │ │ ├── nextdays.png │ │ ├── nimblequiz.png │ │ ├── nuorder.png │ │ ├── panemerkille.png │ │ ├── pictorious.png │ │ ├── scottyapp.png │ │ ├── seelio.png │ │ ├── selectvids.png │ │ ├── sharelatex.png │ │ ├── shoejitsu.png │ │ ├── skim.png │ │ ├── squadsheet.png │ │ ├── stachify.png │ │ ├── storify.png │ │ ├── todaylaunch.png │ │ ├── treinosmart.png │ │ ├── upcload.png │ │ ├── urls │ │ ├── veriwalk.png │ │ ├── wavo.png │ │ └── zootify.png │ └── square_bg.png ├── includes │ ├── googleanalytics.jade │ ├── googlesearch.jade │ └── nav.jade ├── index.html ├── index.jade ├── js │ ├── cookies.min.js │ └── zepto.min.js ├── layout.jade ├── middleware.html ├── middleware.jade ├── migration.html ├── migration.jade ├── models.html ├── models.jade ├── plugins.html ├── plugins.jade ├── populate.html ├── populate.jade ├── prior.html ├── prior.jade ├── production.jade ├── queries.html ├── queries.jade ├── redirect.jade ├── releases ├── schematypes.html ├── schematypes.jade ├── source │ ├── api.js │ ├── home.js │ ├── index.js │ ├── prior.js │ └── production.js ├── subdocs.html ├── subdocs.jade ├── validation.html ├── validation.jade └── website.js ├── examples ├── README.md ├── aggregate │ ├── aggregate.js │ ├── package.json │ └── person.js ├── doc-methods.js ├── express │ ├── README.md │ └── connection-sharing │ │ ├── README.md │ │ ├── app.js │ │ ├── modelA.js │ │ ├── package.json │ │ └── routes.js ├── geospatial │ ├── geoJSONSchema.js │ ├── geoJSONexample.js │ ├── geospatial.js │ ├── package.json │ └── person.js ├── globalschemas │ ├── gs_example.js │ └── person.js ├── lean │ ├── lean.js │ ├── package.json │ └── person.js ├── mapreduce │ ├── mapreduce.js │ ├── package.json │ └── person.js ├── population │ ├── population-across-three-collections.js │ ├── population-basic.js │ ├── population-of-existing-doc.js │ ├── population-of-multiple-existing-docs.js │ ├── population-options.js │ └── population-plain-objects.js ├── promises │ ├── package.json │ ├── person.js │ └── promise.js ├── querybuilder │ ├── package.json │ ├── person.js │ └── querybuilder.js ├── replicasets │ ├── package.json │ ├── person.js │ └── replica-sets.js ├── schema │ ├── schema.js │ └── storing-schemas-as-json │ │ ├── index.js │ │ └── schema.json └── statics │ ├── person.js │ └── statics.js ├── index.html ├── index.jade ├── index.js ├── lib ├── aggregate.js ├── collection.js ├── connection.js ├── connectionstate.js ├── document.js ├── drivers │ ├── SPEC.md │ └── node-mongodb-native │ │ ├── binary.js │ │ ├── collection.js │ │ ├── connection.js │ │ └── objectid.js ├── error.js ├── error │ ├── cast.js │ ├── divergentArray.js │ ├── messages.js │ ├── missingSchema.js │ ├── overwriteModel.js │ ├── validation.js │ ├── validator.js │ └── version.js ├── index.js ├── internal.js ├── model.js ├── promise.js ├── query.js ├── queryhelpers.js ├── querystream.js ├── schema.js ├── schema │ ├── array.js │ ├── boolean.js │ ├── buffer.js │ ├── date.js │ ├── documentarray.js │ ├── index.js │ ├── mixed.js │ ├── number.js │ ├── objectid.js │ └── string.js ├── schemadefault.js ├── schematype.js ├── statemachine.js ├── types │ ├── array.js │ ├── buffer.js │ ├── documentarray.js │ ├── embedded.js │ ├── index.js │ └── objectid.js ├── utils.js └── virtualtype.js ├── package.json ├── release-items.md ├── static.js ├── test ├── _goosetest.js ├── aggregate.test.js ├── collection.capped.test.js ├── collection.test.js ├── common.js ├── connection.auth.test.js ├── connection.reconnect.test.js ├── connection.test.js ├── crash.test.js ├── createtest ├── document.hooks.test.js ├── document.isselected.test.js ├── document.modified.test.js ├── document.populate.test.js ├── document.strict.test.js ├── document.test.js ├── drivers │ └── node-mongodb-native │ │ ├── collection.test.js │ │ └── connection.test.js ├── dropdb.js ├── errors.mongoose.test.js ├── errors.validation.test.js ├── gh-1408.test.js ├── index.test.js ├── model.aggregate.test.js ├── model.create.test.js ├── model.discriminator.querying.test.js ├── model.discriminator.test.js ├── model.field.selection.test.js ├── model.findAndRemoveOne.test.js ├── model.findAndUpdateOne.test.js ├── model.geonear.test.js ├── model.geosearch.test.js ├── model.indexes.test.js ├── model.mapreduce.test.js ├── model.middleware.test.js ├── model.populate.divergent.test.js ├── model.populate.setting.test.js ├── model.populate.test.js ├── model.query.casting.test.js ├── model.querying.test.js ├── model.stream.test.js ├── model.test.js ├── model.update.test.js ├── object.create.null.test.js ├── promise.test.js ├── query.test.js ├── query.toconstructor.test.js ├── schema.boolean.test.js ├── schema.documentarray.test.js ├── schema.mixed.test.js ├── schema.onthefly.test.js ├── schema.select.test.js ├── schema.test.js ├── schema.type.test.js ├── schema.validation.test.js ├── shard.test.js ├── triage │ └── .gitignore ├── types.array.test.js ├── types.buffer.test.js ├── types.document.test.js ├── types.documentarray.test.js ├── types.number.test.js ├── utils.test.js └── versioning.test.js └── website.js /.gitignore: -------------------------------------------------------------------------------- 1 | lib-cov 2 | **.swp 3 | *.sw* 4 | node_modules/ 5 | *.orig 6 | benchmarks/benchmarks 7 | benchmarks/benchmarks2 8 | benchmarks/benchmarks3 9 | benchmarks/v8.log 10 | .DS_Store 11 | docs/*.json 12 | docs/source/_docs 13 | docs/*.html 14 | tags 15 | test/triage/*.js 16 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | lib-cov 2 | **.swp 3 | *.sw* 4 | *.orig 5 | .DS_Store 6 | node_modules/ 7 | benchmarks/ 8 | docs/ 9 | test/ 10 | Makefile 11 | CNAME 12 | index.html 13 | index.jade 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 0.8 4 | - 0.10 5 | services: 6 | - mongodb 7 | -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | mongoosejs.com 2 | -------------------------------------------------------------------------------- /benchmarks/clone.js: -------------------------------------------------------------------------------- 1 | 2 | var mongoose = require('../') 3 | , utils = require('../lib/utils') 4 | , clone = utils.clone 5 | , Schema = mongoose.Schema 6 | 7 | var DocSchema = new Schema({ 8 | title: String 9 | }); 10 | 11 | var AllSchema = new Schema({ 12 | string: { type: String, required: true } 13 | , number: { type: Number, min: 10 } 14 | , date : Date 15 | , bool : Boolean 16 | , buffer: Buffer 17 | , objectid: Schema.ObjectId 18 | , array : Array 19 | , strings: [String] 20 | , numbers: [Number] 21 | , dates : [Date] 22 | , bools : [Boolean] 23 | , buffers: [Buffer] 24 | , objectids: [Schema.ObjectId] 25 | , docs : { type: [DocSchema], validate: function () { return true }} 26 | , s: { nest: String } 27 | }); 28 | 29 | var A = mongoose.model('A', AllSchema); 30 | var a = new A({ 31 | string: "hello world" 32 | , number: 444848484 33 | , date: new Date 34 | , bool: true 35 | , buffer: new Buffer(0) 36 | , objectid: new mongoose.Types.ObjectId() 37 | , array: [4,{},[],"asdfa"] 38 | , strings: ["one","two","three","four"] 39 | , numbers:[72,6493,83984643,348282.55] 40 | , dates:[new Date, new Date, new Date] 41 | , bools:[true, false, false, true, true] 42 | , buffers: [new Buffer([33]), new Buffer([12])] 43 | , objectids: [new mongoose.Types.ObjectId] 44 | , docs: [ {title: "yo"}, {title:"nowafasdi0fas asjkdfla fa" }] 45 | , s: { nest: 'hello there everyone!' } 46 | }); 47 | 48 | var start = new Date; 49 | var total = 100000; 50 | var i = total; 51 | 52 | for (var i = 0, len = total; i < len; ++i) { 53 | a.toObject({ depopulate: true }); 54 | } 55 | 56 | var time= (new Date - start)/1000; 57 | console.error('took %d seconds for %d docs (%d dps)', time, total, total/time); 58 | var used = process.memoryUsage(); 59 | 60 | // --trace-opt --trace-deopt --trace-bailout 61 | -------------------------------------------------------------------------------- /benchmarks/create.js: -------------------------------------------------------------------------------- 1 | //require('nodetime').profile(); 2 | 3 | var mongoose = require('../../mongoose') 4 | var fs = require('fs') 5 | 6 | var Schema = mongoose.Schema; 7 | 8 | CheckItem = new Schema({ 9 | name: { type: String }, 10 | type: { type: String }, 11 | pos: { type: Number }, 12 | }); 13 | 14 | Checklist = new Schema({ 15 | name: { type: String }, 16 | checkItems: { type: [CheckItem] } 17 | }); 18 | 19 | Board = new Schema({ 20 | checklists: { type: [Checklist] } 21 | }); 22 | 23 | var start1 = new Date(); 24 | var Board = mongoose.model('Board', Board); 25 | //var Cl = mongoose.model('Checklist', Checklist); 26 | var doc = JSON.parse(fs.readFileSync(__dirname + '/bigboard.json')); 27 | var time1 = (new Date - start1); 28 | //console.error('reading from disk and parsing JSON took %d ms', time1); 29 | 30 | var start2 = new Date(); 31 | for (var i = 0; i < 1000; ++i) { 32 | var board = new Board(doc); 33 | } 34 | var time2 = (new Date - start2); 35 | console.error('creation of large object took %d ms', time2); 36 | -------------------------------------------------------------------------------- /contRun.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | make test 4 | 5 | ret=$? 6 | 7 | while [ $ret == 0 ]; do 8 | make test 9 | ret=$? 10 | done 11 | -------------------------------------------------------------------------------- /docs/2.7.x/announcement.html: -------------------------------------------------------------------------------- 1 |

Mongoose 2.7.0

2 |
06-18-2012: Mongoose 2.7 is out which is a big 3 | step towards the upcoming 3.0 release. The only change is the 4 | deprecation of many methods. 5 | Check out the release notes for details. 6 |
7 | -------------------------------------------------------------------------------- /docs/2.7.x/docs/style/foot.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/2.7.x/docs/style/head.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{title}} 4 | 5 | 6 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /docs/2.7.x/images/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/2.7.x/images/bg.png -------------------------------------------------------------------------------- /docs/2.7.x/images/groups.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/2.7.x/images/groups.png -------------------------------------------------------------------------------- /docs/2.7.x/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/2.7.x/images/logo.png -------------------------------------------------------------------------------- /docs/2.7.x/images/pattern.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/2.7.x/images/pattern.png -------------------------------------------------------------------------------- /docs/2.8.x/announcement.html: -------------------------------------------------------------------------------- 1 |

Mongoose 2.7.0

2 |
06-18-2012: Mongoose 2.7 is out which is a big 3 | step towards the upcoming 3.0 release. The only change is the 4 | deprecation of many methods. 5 | Check out the release notes for details. 6 |
7 | -------------------------------------------------------------------------------- /docs/2.8.x/docs/style/foot.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/2.8.x/docs/style/head.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{title}} 4 | 5 | 6 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /docs/2.8.x/images/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/2.8.x/images/bg.png -------------------------------------------------------------------------------- /docs/2.8.x/images/groups.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/2.8.x/images/groups.png -------------------------------------------------------------------------------- /docs/2.8.x/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/2.8.x/images/logo.png -------------------------------------------------------------------------------- /docs/2.8.x/images/pattern.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/2.8.x/images/pattern.png -------------------------------------------------------------------------------- /docs/3.0.x/docs/helpers/filters.js: -------------------------------------------------------------------------------- 1 | 2 | var hl = require('highlight.js') 3 | 4 | module.exports = exports = function (jade) { 5 | // add highlighting filter to jade 6 | 7 | jade.filters.js = function (str) { 8 | str = str.replace(/\\n/g, '\n'); 9 | var ret = hl.highlight('javascript', str).value; 10 | var code = '
' + ret.replace(/\n/g, '\\n') + '
'; 11 | return code; 12 | } 13 | 14 | jade.filters.bash = function (str) { 15 | var ret = hl.highlight('bash', str.replace(/\\n/g, '\n')).value; 16 | var code = '
' + ret + '
'; 17 | return code 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /docs/3.0.x/docs/helpers/highlight.js: -------------------------------------------------------------------------------- 1 | 2 | var h = require('highlight.js') 3 | 4 | function hl (str) { 5 | str = str.replace(/\\n/g, '\n'); 6 | var ret = h.highlight('javascript', str).value; 7 | var code = '
' + ret+ '
'; 8 | return code; 9 | } 10 | 11 | module.exports = hl; 12 | -------------------------------------------------------------------------------- /docs/3.0.x/docs/helpers/href.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = exports = function (str, char) { 3 | if ('string' != typeof str) return str; 4 | return encodeURIComponent(str.replace(/\.js$/, '').replace(/\.|#/g, char || '-')); 5 | } 6 | -------------------------------------------------------------------------------- /docs/3.0.x/docs/helpers/klass.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = exports = function (str) { 3 | var parts = str.replace(/\.js$/, '').split('/'); 4 | return parts.join('_'); 5 | } 6 | -------------------------------------------------------------------------------- /docs/3.0.x/docs/images/apps/grab: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #make sure firefox launches in the bottom right corner of the window 4 | 5 | # read URLs from a data file in a loop 6 | #regex='([^[:space:]]+)[[:space:]]*(.*)' 7 | regex='([^[:space:]]+)[|]([^|]+)[|](.*)' 8 | 9 | func() { 10 | [[ $1 =~ $regex ]] 11 | url=${BASH_REMATCH[1]} 12 | # remove middle space, lowercase 13 | name=`echo ${BASH_REMATCH[2]} | tr -d '[[:space:]]' | tr '[A-Z]' '[a-z]'` 14 | desc=${BASH_REMATCH[3]} 15 | 16 | # send URL to the firefox session 17 | # firefox --width 1030 --height 768 $url & 18 | /Applications/Firefox.app/Contents/MacOS/firefox --width 1030 --height 768 $url & 19 | echo started firefox with $url 20 | echo preparing screencapture ... 21 | 22 | # take a picture after waiting a bit for the load to finish 23 | sleep 6 24 | # gm import -window root -crop 1004x768+414+228 -resize 500x350 $name.png 25 | screencapture -wo $name.png 26 | gm convert $name.png -crop 1004x768+0+80 -resize 200x140 $name.png 27 | echo grabbed screenshot $name.png 28 | } 29 | 30 | if [ $1 ] 31 | then 32 | func "$1 $2" 33 | else 34 | while read line 35 | do 36 | func $line 37 | done < urls 38 | fi 39 | 40 | -------------------------------------------------------------------------------- /docs/3.0.x/docs/images/square_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.0.x/docs/images/square_bg.png -------------------------------------------------------------------------------- /docs/3.0.x/docs/includes/googleanalytics.jade: -------------------------------------------------------------------------------- 1 | script. 2 | var _gaq = _gaq || []; 3 | _gaq.push(['_setAccount', 'UA-1122274-9']); 4 | _gaq.push(['_trackPageview']); 5 | 6 | (function() { 7 | var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 8 | ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 9 | var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); 10 | })(); 11 | -------------------------------------------------------------------------------- /docs/3.0.x/docs/includes/nav.jade: -------------------------------------------------------------------------------- 1 | ul 2 | li.home 3 | a(href="../index.html") home 4 | li.faq 5 | a(href="./faq.html") FAQ 6 | li.plugins 7 | a(href="http://plugins.mongoosejs.com") plugins 8 | li.changelog 9 | a(href="http://github.com/learnboost/mongoose/tree/master/History.md") change log 10 | li.support 11 | a(href="../index.html#support") support 12 | li.fork 13 | a(href="http://github.com/learnboost/mongoose") fork 14 | li.guide 15 | a(href="./guide.html") guide 16 | if (locals.guide) 17 | ul 18 | li.double 19 | a(href="./guide.html") schemas 20 | ul 21 | li.schematypes 22 | a(href="./schematypes.html") 23 | span schema 24 | | types 25 | li.double 26 | a(href="./documents.html") documents 27 | ul 28 | li.subdocs 29 | a(href="./subdocs.html") sub docs 30 | li 31 | a(href="./models.html") models 32 | li 33 | a(href="./queries.html") queries 34 | li 35 | a(href="./plugins.html") plugins 36 | li 37 | a(href="./middleware.html") middleware 38 | li 39 | a(href="./validation.html") validation 40 | li 41 | a(href="./populate.html") populate 42 | li 43 | a(href="./migration.html") migrating from 2.x 44 | li 45 | a(href="./contributing.html") contributing 46 | li.api 47 | a(href="./api.html") api docs 48 | li.quickstart 49 | a(href="./index.html") quick start 50 | li.contrib 51 | a(href="http://github.com/learnboost/mongoose/contributors") contributors 52 | li.prior 53 | a(href="./prior.html") prior releases 54 | -------------------------------------------------------------------------------- /docs/3.0.x/docs/layout.jade: -------------------------------------------------------------------------------- 1 | doctype html 2 | html(lang='en') 3 | head 4 | meta(charset="utf-8") 5 | meta(name="viewport", content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no") 6 | title Mongoose #{title} v#{package.version} 7 | block style 8 | link(href='http://fonts.googleapis.com/css?family=Anonymous+Pro:400,700|Droid+Sans+Mono|Open+Sans:400,700|Linden+Hill|Quattrocento:400,700|News+Cycle:400,700|Antic+Slab|Cabin+Condensed:400,700', rel='stylesheet', type='text/css') 9 | link(href='css/default.css', rel='stylesheet', type='text/css') 10 | link(href='css/guide.css', rel='stylesheet', type='text/css') 11 | body 12 | a#forkbanner(href="http://github.com/learnboost/mongoose") 13 | img(style="position: absolute; top: 0; right: 0; border: 0;", src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png", alt="Fork me on GitHub") 14 | #links 15 | #header 16 | h1 17 | a(href="../index.html") 18 | .mongoose Mongoose 19 | include includes/nav 20 | #content 21 | .module 22 | block content 23 | script. 24 | document.body.className = 'load'; 25 | include includes/googleanalytics 26 | -------------------------------------------------------------------------------- /docs/3.0.x/docs/plugins.jade: -------------------------------------------------------------------------------- 1 | extends layout 2 | 3 | block content 4 | h2 Plugins 5 | :markdown 6 | Schemas are pluggable, that is, they allow for applying pre-packaged capabilities to extend their functionality. This is a very powerful feature. 7 | 8 | Suppose that we have several collections in our database and want to add last-modified functionality to each one. With plugins this is easy. Just create a plugin once and apply it to each `Schema`: 9 | 10 | :js 11 | // lastMod.js 12 | module.exports = exports = function lastModifiedPlugin (schema, options) { 13 | schema.add({ lastMod: Date }) 14 | 15 | schema.pre('save', function (next) { 16 | this.lastMod = new Date 17 | next() 18 | }) 19 | 20 | if (options && options.index) { 21 | schema.path('lastMod').index(options.index) 22 | } 23 | } 24 | 25 | // game-schema.js 26 | var lastMod = require('./lastMod'); 27 | var Game = new Schema({ ... }); 28 | Game.plugin(lastMod, { index: true }); 29 | 30 | // player-schema.js 31 | var lastMod = require('./lastMod'); 32 | var Player = new Schema({ ... }); 33 | Player.plugin(lastMod); 34 | :markdown 35 | We just added last-modified behavior to both our `Game` and `Player` schemas and declared an index on the `lastMod` path of our Games to boot. Not bad for a few lines of code. 36 | h3 Community! 37 | :markdown 38 | Not only can you re-use schema functionality in your own projects but you also reap the benefits of the Mongoose community as well. Any plugin published to [npm](https://npmjs.org/) and [tagged](https://npmjs.org/doc/tag.html) with `mongoose` will show up on our [search results](http://plugins.mongoosejs.com) page. 39 | -------------------------------------------------------------------------------- /docs/3.0.x/docs/prior.jade: -------------------------------------------------------------------------------- 1 | extends layout 2 | 3 | block content 4 | h2 Prior Release Documentation 5 | ul 6 | each release in releases 7 | li 8 | a(href=release.url)= release.version 9 | -------------------------------------------------------------------------------- /docs/3.0.x/docs/releases: -------------------------------------------------------------------------------- 1 | 2.7.x 2 | -------------------------------------------------------------------------------- /docs/3.0.x/docs/source/home.js: -------------------------------------------------------------------------------- 1 | 2 | var fs = require('fs') 3 | var package = require('./../../package.json') 4 | var images = fs.readFileSync(__dirname + '/../images/apps/urls', 'utf-8').split('\n'); 5 | 6 | var imgs = []; 7 | 8 | images.forEach(function (line) { 9 | line = line.trim(); 10 | if (!line) return; 11 | line = line.split('|'); 12 | imgs.push({ url: line[0], title: line[1], desc: line[2], src: line[1].toLowerCase().replace(/\s/g,'') }); 13 | }); 14 | 15 | module.exports = { 16 | package: package 17 | , images: imgs 18 | , title: 'ODM' 19 | } 20 | -------------------------------------------------------------------------------- /docs/3.0.x/docs/source/index.js: -------------------------------------------------------------------------------- 1 | 2 | exports['index.jade'] = require('./home') 3 | exports['docs/api.jade'] = require('./api') 4 | exports['docs/index.jade'] = { title: 'Getting Started' } 5 | exports['docs/prior.jade'] = require('./prior') 6 | exports['docs/guide.jade'] = { guide: true, schema: true, title: 'Schemas' } 7 | exports['docs/schematypes.jade'] = { guide: true, schema: true, title: 'SchemaTypes' } 8 | exports['docs/middleware.jade'] = { guide: true, title: 'Middleware' } 9 | exports['docs/plugins.jade'] = { guide: true, title: 'Plugins' } 10 | exports['docs/subdocs.jade'] = { guide: true, docs: true, title: 'SubDocuments' } 11 | exports['docs/models.jade'] = { guide: true, title: 'Models' } 12 | exports['docs/queries.jade'] = { guide: true, title: 'Queries' } 13 | exports['docs/documents.jade'] = { guide: true, docs: true, title: 'Documents' } 14 | exports['docs/populate.jade'] = { guide: true, title: 'Query Population' } 15 | exports['docs/validation.jade'] = { guide: true, title: 'Validation' } 16 | exports['docs/migration.jade'] = { guide: true, title: 'Migration Guide' } 17 | exports['docs/contributing.jade'] = { guide: true, title: 'Contributing' } 18 | exports['docs/faq.jade'] = { guide: true, title: 'FAQ' } 19 | -------------------------------------------------------------------------------- /docs/3.0.x/docs/source/prior.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs') 2 | var releases = fs.readFileSync(__dirname + '/../releases', 'utf8'); 3 | releases = releases.split('\n').filter(Boolean); 4 | 5 | module.exports = exports = { 6 | title: '' 7 | , releases: releases.map(function (version) { 8 | return { 9 | url: version + '/' 10 | , version: version 11 | } 12 | }) 13 | } 14 | -------------------------------------------------------------------------------- /docs/3.0.x/static.js: -------------------------------------------------------------------------------- 1 | 2 | var static = require('node-static'); 3 | var server = new static.Server('.', { cache: 0 }); 4 | 5 | require('http').createServer(function (req, res) { 6 | req.on('end', function () { 7 | server.serve(req, res, function (err) { 8 | if (err) { 9 | console.error(err, req.url); 10 | res.writeHead(err.status, err.headers); 11 | res.end(); 12 | } 13 | }); 14 | }); 15 | }).listen(8088); 16 | 17 | console.error('now listening on localhost:8088'); 18 | -------------------------------------------------------------------------------- /docs/3.1.x/docs/helpers/filters.js: -------------------------------------------------------------------------------- 1 | 2 | var hl = require('highlight.js') 3 | 4 | module.exports = exports = function (jade) { 5 | // add highlighting filter to jade 6 | 7 | jade.filters.js = function (str) { 8 | str = str.replace(/\\n/g, '\n'); 9 | var ret = hl.highlight('javascript', str).value; 10 | var code = '
' + ret.replace(/\n/g, '\\n') + '
'; 11 | return code; 12 | } 13 | 14 | jade.filters.bash = function (str) { 15 | var ret = hl.highlight('bash', str.replace(/\\n/g, '\n')).value; 16 | var code = '
' + ret + '
'; 17 | return code 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /docs/3.1.x/docs/helpers/highlight.js: -------------------------------------------------------------------------------- 1 | 2 | var h = require('highlight.js') 3 | 4 | function hl (str) { 5 | str = str.replace(/\\n/g, '\n'); 6 | var ret = h.highlight('javascript', str).value; 7 | var code = '
' + ret+ '
'; 8 | return code; 9 | } 10 | 11 | module.exports = hl; 12 | -------------------------------------------------------------------------------- /docs/3.1.x/docs/helpers/href.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = exports = function (str, char) { 3 | if ('string' != typeof str) return str; 4 | return encodeURIComponent(str.replace(/\.js$/, '').replace(/\.|#/g, char || '-')); 5 | } 6 | -------------------------------------------------------------------------------- /docs/3.1.x/docs/helpers/klass.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = exports = function (str) { 3 | var parts = str.replace(/\.js$/, '').split('/'); 4 | return parts.join('_'); 5 | } 6 | -------------------------------------------------------------------------------- /docs/3.1.x/docs/images/apps/grab: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #make sure firefox launches in the bottom right corner of the window 4 | 5 | # read URLs from a data file in a loop 6 | #regex='([^[:space:]]+)[[:space:]]*(.*)' 7 | regex='([^[:space:]]+)[|]([^|]+)[|](.*)' 8 | 9 | func() { 10 | [[ $1 =~ $regex ]] 11 | url=${BASH_REMATCH[1]} 12 | # remove middle space, lowercase 13 | name=`echo ${BASH_REMATCH[2]} | tr -d '[[:space:]]' | tr '[A-Z]' '[a-z]'` 14 | desc=${BASH_REMATCH[3]} 15 | 16 | # send URL to the firefox session 17 | # firefox --width 1030 --height 768 $url & 18 | /Applications/Firefox.app/Contents/MacOS/firefox --width 1030 --height 768 $url & 19 | echo started firefox with $url 20 | echo preparing screencapture ... 21 | 22 | # take a picture after waiting a bit for the load to finish 23 | sleep 6 24 | # gm import -window root -crop 1004x768+414+228 -resize 500x350 $name.png 25 | screencapture -wo $name.png 26 | gm convert $name.png -crop 1004x768+0+80 -resize 200x140 $name.png 27 | echo grabbed screenshot $name.png 28 | } 29 | 30 | if [ $1 ] 31 | then 32 | func "$1 $2" 33 | else 34 | while read line 35 | do 36 | func $line 37 | done < urls 38 | fi 39 | 40 | -------------------------------------------------------------------------------- /docs/3.1.x/docs/images/square_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.1.x/docs/images/square_bg.png -------------------------------------------------------------------------------- /docs/3.1.x/docs/includes/googleanalytics.jade: -------------------------------------------------------------------------------- 1 | script. 2 | var _gaq = _gaq || []; 3 | _gaq.push(['_setAccount', 'UA-1122274-9']); 4 | _gaq.push(['_trackPageview']); 5 | 6 | (function() { 7 | var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 8 | ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 9 | var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); 10 | })(); 11 | -------------------------------------------------------------------------------- /docs/3.1.x/docs/includes/nav.jade: -------------------------------------------------------------------------------- 1 | ul 2 | li.home 3 | a(href="../index.html") home 4 | li.faq 5 | a(href="./faq.html") FAQ 6 | li.plugins 7 | a(href="http://plugins.mongoosejs.com") plugins 8 | li.changelog 9 | a(href="http://github.com/learnboost/mongoose/tree/master/History.md") change log 10 | li.support 11 | a(href="../index.html#support") support 12 | li.fork 13 | a(href="http://github.com/learnboost/mongoose") fork 14 | li.guide 15 | a(href="./guide.html") guide 16 | if (locals.guide) 17 | ul 18 | li.double 19 | a(href="./guide.html") schemas 20 | ul 21 | li.schematypes 22 | a(href="./schematypes.html") 23 | span schema 24 | | types 25 | li.double 26 | a(href="./documents.html") documents 27 | ul 28 | li.subdocs 29 | a(href="./subdocs.html") sub docs 30 | li 31 | a(href="./models.html") models 32 | li 33 | a(href="./queries.html") queries 34 | li 35 | a(href="./validation.html") validation 36 | li 37 | a(href="./middleware.html") middleware 38 | li 39 | a(href="./populate.html") population 40 | li 41 | a(href="./plugins.html") plugins 42 | li 43 | a(href="./contributing.html") contributing 44 | li 45 | a(href="./migration.html") migrating from 2.x 46 | li.api 47 | a(href="./api.html") api docs 48 | li.quickstart 49 | a(href="./index.html") quick start 50 | li.contrib 51 | a(href="http://github.com/learnboost/mongoose/contributors") contributors 52 | li.prior 53 | a(href="./prior.html") prior releases 54 | -------------------------------------------------------------------------------- /docs/3.1.x/docs/layout.jade: -------------------------------------------------------------------------------- 1 | doctype html 2 | html(lang='en') 3 | head 4 | meta(charset="utf-8") 5 | meta(name="viewport", content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no") 6 | title Mongoose #{title} v#{package.version} 7 | block style 8 | link(href='http://fonts.googleapis.com/css?family=Anonymous+Pro:400,700|Droid+Sans+Mono|Open+Sans:400,700|Linden+Hill|Quattrocento:400,700|News+Cycle:400,700|Antic+Slab|Cabin+Condensed:400,700', rel='stylesheet', type='text/css') 9 | link(href='css/default.css', rel='stylesheet', type='text/css') 10 | link(href='css/guide.css', rel='stylesheet', type='text/css') 11 | body 12 | a#forkbanner(href="http://github.com/learnboost/mongoose") 13 | img(style="position: absolute; top: 0; right: 0; border: 0;", src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png", alt="Fork me on GitHub") 14 | #links 15 | #header 16 | h1 17 | a(href="../index.html") 18 | .mongoose Mongoose 19 | include includes/nav 20 | #content 21 | .module 22 | block content 23 | script. 24 | document.body.className = 'load'; 25 | include includes/googleanalytics 26 | -------------------------------------------------------------------------------- /docs/3.1.x/docs/prior.jade: -------------------------------------------------------------------------------- 1 | extends layout 2 | 3 | block content 4 | h2 Prior Release Documentation 5 | ul 6 | each release in releases 7 | li 8 | a(href=release.url)= release.version 9 | -------------------------------------------------------------------------------- /docs/3.1.x/docs/releases: -------------------------------------------------------------------------------- 1 | 2.8.x 2 | 2.7.x 3 | -------------------------------------------------------------------------------- /docs/3.1.x/docs/source/home.js: -------------------------------------------------------------------------------- 1 | 2 | var fs = require('fs') 3 | var package = require('./../../package.json') 4 | var images = fs.readFileSync(__dirname + '/../images/apps/urls', 'utf-8').split('\n'); 5 | 6 | var imgs = []; 7 | 8 | images.forEach(function (line) { 9 | line = line.trim(); 10 | if (!line) return; 11 | line = line.split('|'); 12 | imgs.push({ url: line[0], title: line[1], desc: line[2], src: line[1].toLowerCase().replace(/\s/g,'') }); 13 | }); 14 | 15 | module.exports = { 16 | package: package 17 | , images: imgs 18 | , title: 'ODM' 19 | } 20 | -------------------------------------------------------------------------------- /docs/3.1.x/docs/source/index.js: -------------------------------------------------------------------------------- 1 | 2 | exports['index.jade'] = require('./home') 3 | exports['docs/api.jade'] = require('./api') 4 | exports['docs/index.jade'] = { title: 'Getting Started' } 5 | exports['docs/prior.jade'] = require('./prior') 6 | exports['docs/guide.jade'] = { guide: true, schema: true, title: 'Schemas' } 7 | exports['docs/schematypes.jade'] = { guide: true, schema: true, title: 'SchemaTypes' } 8 | exports['docs/middleware.jade'] = { guide: true, title: 'Middleware' } 9 | exports['docs/plugins.jade'] = { guide: true, title: 'Plugins' } 10 | exports['docs/subdocs.jade'] = { guide: true, docs: true, title: 'SubDocuments' } 11 | exports['docs/models.jade'] = { guide: true, title: 'Models' } 12 | exports['docs/queries.jade'] = { guide: true, title: 'Queries' } 13 | exports['docs/documents.jade'] = { guide: true, docs: true, title: 'Documents' } 14 | exports['docs/populate.jade'] = { guide: true, title: 'Query Population' } 15 | exports['docs/validation.jade'] = { guide: true, title: 'Validation' } 16 | exports['docs/migration.jade'] = { guide: true, title: 'Migration Guide' } 17 | exports['docs/contributing.jade'] = { guide: true, title: 'Contributing' } 18 | exports['docs/faq.jade'] = { guide: true, title: 'FAQ' } 19 | -------------------------------------------------------------------------------- /docs/3.1.x/docs/source/prior.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs') 2 | var releases = fs.readFileSync(__dirname + '/../releases', 'utf8'); 3 | releases = releases.split('\n').filter(Boolean); 4 | 5 | module.exports = exports = { 6 | title: '' 7 | , releases: releases.map(function (version) { 8 | return { 9 | url: version + '/' 10 | , version: version 11 | } 12 | }) 13 | } 14 | -------------------------------------------------------------------------------- /docs/3.1.x/static.js: -------------------------------------------------------------------------------- 1 | 2 | var static = require('node-static'); 3 | var server = new static.Server('.', { cache: 0 }); 4 | 5 | require('http').createServer(function (req, res) { 6 | req.on('end', function () { 7 | server.serve(req, res, function (err) { 8 | if (err) { 9 | console.error(err, req.url); 10 | res.writeHead(err.status, err.headers); 11 | res.end(); 12 | } 13 | }); 14 | }); 15 | }).listen(8088); 16 | 17 | console.error('now listening on localhost:8088'); 18 | -------------------------------------------------------------------------------- /docs/3.2.x/docs/contributing.jade: -------------------------------------------------------------------------------- 1 | extends layout 2 | 3 | block content 4 | h2 Contributing 5 | 6 | :markdown 7 | Please read all about contributing [here](https://github.com/LearnBoost/mongoose/blob/master/CONTRIBUTING.md). 8 | 9 | -------------------------------------------------------------------------------- /docs/3.2.x/docs/helpers/filters.js: -------------------------------------------------------------------------------- 1 | 2 | var hl = require('highlight.js') 3 | 4 | module.exports = exports = function (jade) { 5 | // add highlighting filter to jade 6 | 7 | jade.filters.js = function (str) { 8 | str = str.replace(/\\n/g, '\n'); 9 | var ret = hl.highlight('javascript', str).value; 10 | var code = '
' + ret.replace(/\n/g, '\\n') + '
'; 11 | return code; 12 | } 13 | 14 | jade.filters.bash = function (str) { 15 | var ret = hl.highlight('bash', str.replace(/\\n/g, '\n')).value; 16 | var code = '
' + ret + '
'; 17 | return code 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /docs/3.2.x/docs/helpers/highlight.js: -------------------------------------------------------------------------------- 1 | 2 | var h = require('highlight.js') 3 | 4 | function hl (str) { 5 | str = str.replace(/\\n/g, '\n'); 6 | var ret = h.highlight('javascript', str).value; 7 | var code = '
' + ret+ '
'; 8 | return code; 9 | } 10 | 11 | module.exports = hl; 12 | -------------------------------------------------------------------------------- /docs/3.2.x/docs/helpers/href.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = exports = function (str, char) { 3 | if ('string' != typeof str) return str; 4 | return encodeURIComponent(str.replace(/\.js$/, '').replace(/\.|#/g, char || '-')); 5 | } 6 | -------------------------------------------------------------------------------- /docs/3.2.x/docs/helpers/klass.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = exports = function (str) { 3 | var parts = str.replace(/\.js$/, '').split('/'); 4 | return parts.join('_'); 5 | } 6 | -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/attictv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/attictv.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/bozuko.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/bozuko.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/calllist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/calllist.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/cldfy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/cldfy.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/clickdummy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/clickdummy.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/cyborgvision.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/cyborgvision.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/furbabyrescue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/furbabyrescue.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/geeklist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/geeklist.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/grab: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #make sure firefox launches in the bottom right corner of the window 4 | 5 | # read URLs from a data file in a loop 6 | #regex='([^[:space:]]+)[[:space:]]*(.*)' 7 | regex='([^[:space:]]+)[|]([^|]+)[|](.*)' 8 | 9 | func() { 10 | if [ -n "$2" ] 11 | then 12 | url=$1 13 | name=$2 14 | else 15 | [[ $1 =~ $regex ]] 16 | url=${BASH_REMATCH[1]} 17 | name=${BASH_REMATCH[2]} 18 | desc=${BASH_REMATCH[3]} 19 | fi 20 | 21 | # remove middle space, lowercase 22 | name=`echo $name | tr -d '[[:space:]]' | tr '[A-Z]' '[a-z]'` 23 | 24 | if [ -n "$name" ] 25 | then 26 | close_firefox 27 | 28 | # send URL to the firefox session 29 | # firefox --width 1030 --height 768 $url & 30 | /Applications/Firefox.app/Contents/MacOS/firefox --width 1030 --height 768 $url & 31 | echo started firefox with $url 32 | echo preparing screencapture ... 33 | 34 | # take a picture after waiting a bit for the load to finish 35 | sleep 6 36 | # gm import -window root -crop 1004x768+414+228 -resize 500x350 $name.png 37 | screencapture -wo $name.png 38 | gm convert $name.png -crop 1004x768+0+80 -resize 200x140 $name.png 39 | echo grabbed screenshot $name.png 40 | else 41 | echo missing name $1 $2 42 | fi 43 | } 44 | 45 | close_firefox() { 46 | if ps ax | grep -v grep | grep firefox > /dev/null 47 | then 48 | echo waiting for manual firefox shutdown... 49 | fi 50 | 51 | while true; do 52 | if ps ax | grep -v grep | grep firefox > /dev/null 53 | then 54 | sleep 1 55 | else 56 | break 57 | fi 58 | done 59 | echo firefox shutdown detected 60 | } 61 | 62 | if test -z "$1" 63 | then 64 | while read line 65 | do 66 | func $line 67 | done < urls 68 | else 69 | func $1 "$2" 70 | fi 71 | 72 | -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/growthegamegolf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/growthegamegolf.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/kyyti.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/kyyti.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/learnboost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/learnboost.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/linkr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/linkr.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/lists.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/lists.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/localresponse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/localresponse.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/nextdays.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/nextdays.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/nimblequiz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/nimblequiz.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/nuorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/nuorder.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/scottyapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/scottyapp.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/seelio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/seelio.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/selectvids.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/selectvids.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/sharelatex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/sharelatex.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/shoejitsu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/shoejitsu.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/skim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/skim.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/stachify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/stachify.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/storify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/storify.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/todaylaunch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/todaylaunch.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/treinosmart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/treinosmart.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/upcload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/upcload.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/apps/wavo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/apps/wavo.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/images/square_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.2.x/docs/images/square_bg.png -------------------------------------------------------------------------------- /docs/3.2.x/docs/includes/googleanalytics.jade: -------------------------------------------------------------------------------- 1 | script. 2 | var _gaq = _gaq || []; 3 | _gaq.push(['_setAccount', 'UA-1122274-9']); 4 | _gaq.push(['_trackPageview']); 5 | 6 | (function() { 7 | var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 8 | ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 9 | var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); 10 | })(); 11 | -------------------------------------------------------------------------------- /docs/3.2.x/docs/includes/nav.jade: -------------------------------------------------------------------------------- 1 | ul 2 | li.home 3 | a(href="../index.html") home 4 | li.faq 5 | a(href="./faq.html") FAQ 6 | li.plugins 7 | a(href="http://plugins.mongoosejs.com") plugins 8 | li.changelog 9 | a(href="http://github.com/learnboost/mongoose/tree/master/History.md") change log 10 | li.support 11 | a(href="../index.html#support") support 12 | li.fork 13 | a(href="http://github.com/learnboost/mongoose") fork 14 | li.guide 15 | a(href="./guide.html") guide 16 | if (locals.guide) 17 | ul 18 | li.double 19 | a(href="./guide.html") schemas 20 | ul 21 | li.schematypes 22 | a(href="./schematypes.html") 23 | span schema 24 | | types 25 | li 26 | a(href="./models.html") models 27 | li.double 28 | a(href="./documents.html") documents 29 | ul 30 | li.subdocs 31 | a(href="./subdocs.html") sub docs 32 | li 33 | a(href="./queries.html") queries 34 | li 35 | a(href="./validation.html") validation 36 | li 37 | a(href="./middleware.html") middleware 38 | li 39 | a(href="./populate.html") population 40 | li 41 | a(href="./connections.html") connections 42 | li 43 | a(href="./plugins.html") plugins 44 | li 45 | a(href="https://github.com/LearnBoost/mongoose/blob/master/CONTRIBUTING.md") contributing 46 | li 47 | a(href="./migration.html") migrating from 2.x 48 | li.api 49 | a(href="./api.html") api docs 50 | li.quickstart 51 | a(href="./index.html") quick start 52 | li.contrib 53 | a(href="http://github.com/learnboost/mongoose/contributors") contributors 54 | li.prior 55 | a(href="./prior.html") prior releases 56 | -------------------------------------------------------------------------------- /docs/3.2.x/docs/layout.jade: -------------------------------------------------------------------------------- 1 | doctype html 2 | html(lang='en') 3 | head 4 | meta(charset="utf-8") 5 | meta(name="viewport", content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no") 6 | title Mongoose #{title} v#{package.version} 7 | block style 8 | link(href='http://fonts.googleapis.com/css?family=Anonymous+Pro:400,700|Droid+Sans+Mono|Open+Sans:400,700|Linden+Hill|Quattrocento:400,700|News+Cycle:400,700|Antic+Slab|Cabin+Condensed:400,700', rel='stylesheet', type='text/css') 9 | link(href='css/default.css', rel='stylesheet', type='text/css') 10 | link(href='css/guide.css', rel='stylesheet', type='text/css') 11 | body 12 | a#forkbanner(href="http://github.com/learnboost/mongoose") 13 | img(style="position: absolute; top: 0; right: 0; border: 0;", src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png", alt="Fork me on GitHub") 14 | #links 15 | #header 16 | h1 17 | a(href="../index.html") 18 | .mongoose Mongoose 19 | include includes/nav 20 | #content 21 | .module 22 | block content 23 | script. 24 | document.body.className = 'load'; 25 | include includes/googleanalytics 26 | -------------------------------------------------------------------------------- /docs/3.2.x/docs/prior.jade: -------------------------------------------------------------------------------- 1 | extends layout 2 | 3 | block content 4 | h2 Prior Release Documentation 5 | ul 6 | each release in releases 7 | li 8 | a(href=release.url)= release.version 9 | -------------------------------------------------------------------------------- /docs/3.2.x/docs/releases: -------------------------------------------------------------------------------- 1 | 2.8.x 2 | 2.7.x 3 | -------------------------------------------------------------------------------- /docs/3.2.x/docs/source/home.js: -------------------------------------------------------------------------------- 1 | 2 | var fs = require('fs') 3 | var package = require('./../../package.json') 4 | var images = fs.readFileSync(__dirname + '/../images/apps/urls', 'utf-8').split('\n'); 5 | 6 | var imgs = []; 7 | 8 | images.forEach(function (line) { 9 | line = line.trim(); 10 | if (!line) return; 11 | line = line.split('|'); 12 | imgs.push({ url: line[0], title: line[1], desc: line[2], src: line[1].toLowerCase().replace(/\s/g,'') }); 13 | }); 14 | 15 | module.exports = { 16 | package: package 17 | , images: imgs 18 | , title: 'ODM' 19 | } 20 | -------------------------------------------------------------------------------- /docs/3.2.x/docs/source/index.js: -------------------------------------------------------------------------------- 1 | 2 | exports['index.jade'] = require('./home') 3 | exports['docs/api.jade'] = require('./api') 4 | exports['docs/index.jade'] = { title: 'Getting Started' } 5 | exports['docs/prior.jade'] = require('./prior') 6 | exports['docs/guide.jade'] = { guide: true, schema: true, title: 'Schemas' } 7 | exports['docs/schematypes.jade'] = { guide: true, schema: true, title: 'SchemaTypes' } 8 | exports['docs/middleware.jade'] = { guide: true, title: 'Middleware' } 9 | exports['docs/plugins.jade'] = { guide: true, title: 'Plugins' } 10 | exports['docs/subdocs.jade'] = { guide: true, docs: true, title: 'SubDocuments' } 11 | exports['docs/documents.jade'] = { guide: true, docs: true, title: 'Documents' } 12 | exports['docs/models.jade'] = { guide: true, title: 'Models' } 13 | exports['docs/queries.jade'] = { guide: true, title: 'Queries' } 14 | exports['docs/populate.jade'] = { guide: true, title: 'Query Population' } 15 | exports['docs/validation.jade'] = { guide: true, title: 'Validation' } 16 | exports['docs/migration.jade'] = { guide: true, title: 'Migration Guide' } 17 | exports['docs/contributing.jade'] = { guide: true, title: 'Contributing' } 18 | exports['docs/connections.jade'] = { guide: true, title: 'Connecting to MongoDB' } 19 | exports['docs/faq.jade'] = { guide: true, title: 'FAQ' } 20 | -------------------------------------------------------------------------------- /docs/3.2.x/docs/source/prior.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs') 2 | var releases = fs.readFileSync(__dirname + '/../releases', 'utf8'); 3 | releases = releases.split('\n').filter(Boolean); 4 | 5 | module.exports = exports = { 6 | title: '' 7 | , releases: releases.map(function (version) { 8 | return { 9 | url: version + '/' 10 | , version: version 11 | } 12 | }) 13 | } 14 | -------------------------------------------------------------------------------- /docs/3.2.x/static.js: -------------------------------------------------------------------------------- 1 | 2 | var static = require('node-static'); 3 | var server = new static.Server('.', { cache: 0 }); 4 | 5 | require('http').createServer(function (req, res) { 6 | req.on('end', function () { 7 | server.serve(req, res, function (err) { 8 | if (err) { 9 | console.error(err, req.url); 10 | res.writeHead(err.status, err.headers); 11 | res.end(); 12 | } 13 | }); 14 | }); 15 | }).listen(8088); 16 | 17 | console.error('now listening on localhost:8088'); 18 | -------------------------------------------------------------------------------- /docs/3.3.x/docs/contributing.jade: -------------------------------------------------------------------------------- 1 | extends layout 2 | 3 | block content 4 | h2 Contributing 5 | 6 | :markdown 7 | Please read all about contributing [here](https://github.com/LearnBoost/mongoose/blob/master/CONTRIBUTING.md). 8 | 9 | -------------------------------------------------------------------------------- /docs/3.3.x/docs/helpers/filters.js: -------------------------------------------------------------------------------- 1 | 2 | var hl = require('highlight.js') 3 | 4 | module.exports = exports = function (jade) { 5 | // add highlighting filter to jade 6 | 7 | jade.filters.js = function (str) { 8 | str = str.replace(/\\n/g, '\n'); 9 | var ret = hl.highlight('javascript', str).value; 10 | var code = '
' + ret.replace(/\n/g, '\\n') + '
'; 11 | return code; 12 | } 13 | 14 | jade.filters.bash = function (str) { 15 | var ret = hl.highlight('bash', str.replace(/\\n/g, '\n')).value; 16 | var code = '
' + ret + '
'; 17 | return code 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /docs/3.3.x/docs/helpers/highlight.js: -------------------------------------------------------------------------------- 1 | 2 | var h = require('highlight.js') 3 | 4 | function hl (str) { 5 | str = str.replace(/\\n/g, '\n'); 6 | var ret = h.highlight('javascript', str).value; 7 | var code = '
' + ret+ '
'; 8 | return code; 9 | } 10 | 11 | module.exports = hl; 12 | -------------------------------------------------------------------------------- /docs/3.3.x/docs/helpers/href.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = exports = function (str, char) { 3 | if ('string' != typeof str) return str; 4 | return encodeURIComponent(str.replace(/\.js$/, '').replace(/\.|#/g, char || '-')); 5 | } 6 | -------------------------------------------------------------------------------- /docs/3.3.x/docs/helpers/klass.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = exports = function (str) { 3 | var parts = str.replace(/\.js$/, '').split('/'); 4 | return parts.join('_'); 5 | } 6 | -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/attictv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/attictv.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/bozuko.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/bozuko.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/calllist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/calllist.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/cldfy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/cldfy.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/clickdummy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/clickdummy.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/cyborgvision.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/cyborgvision.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/dashku.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/dashku.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/firstimpression.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/firstimpression.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/furbabyrescue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/furbabyrescue.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/geeklist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/geeklist.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/grab: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #make sure firefox launches in the bottom right corner of the window 4 | 5 | # read URLs from a data file in a loop 6 | #regex='([^[:space:]]+)[[:space:]]*(.*)' 7 | regex='([^[:space:]]+)[|]([^|]+)[|](.*)' 8 | 9 | func() { 10 | if [ -n "$2" ] 11 | then 12 | url=$1 13 | name=$2 14 | else 15 | [[ $1 =~ $regex ]] 16 | url=${BASH_REMATCH[1]} 17 | name=${BASH_REMATCH[2]} 18 | desc=${BASH_REMATCH[3]} 19 | fi 20 | 21 | # remove middle space, lowercase 22 | name=`echo $name | tr -d '[[:space:]]' | tr '[A-Z]' '[a-z]'` 23 | 24 | if [ -n "$name" ] 25 | then 26 | close_firefox 27 | 28 | # send URL to the firefox session 29 | # firefox --width 1030 --height 768 $url & 30 | /Applications/Firefox.app/Contents/MacOS/firefox --width 1030 --height 768 $url & 31 | echo started firefox with $url 32 | echo preparing screencapture ... 33 | 34 | # take a picture after waiting a bit for the load to finish 35 | sleep 6 36 | # gm import -window root -crop 1004x768+414+228 -resize 500x350 $name.png 37 | screencapture -wo $name.png 38 | gm convert $name.png -crop 1004x768+0+80 -resize 200x140 $name.png 39 | echo grabbed screenshot $name.png 40 | else 41 | echo missing name $1 $2 42 | fi 43 | } 44 | 45 | close_firefox() { 46 | if ps ax | grep -v grep | grep firefox > /dev/null 47 | then 48 | echo waiting for manual firefox shutdown... 49 | fi 50 | 51 | while true; do 52 | if ps ax | grep -v grep | grep firefox > /dev/null 53 | then 54 | sleep 1 55 | else 56 | break 57 | fi 58 | done 59 | echo firefox shutdown detected 60 | } 61 | 62 | if test -z "$1" 63 | then 64 | while read line 65 | do 66 | func $line 67 | done < urls 68 | else 69 | func $1 "$2" 70 | fi 71 | 72 | -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/growthegamegolf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/growthegamegolf.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/h_bozuko.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/h_bozuko.jpg -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/h_geeklist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/h_geeklist.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/h_learnboost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/h_learnboost.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/h_mcds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/h_mcds.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/h_shoejitsu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/h_shoejitsu.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/h_storify.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/h_storify.jpg -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/kyyti.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/kyyti.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/learnboost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/learnboost.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/linkr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/linkr.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/lists.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/lists.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/localresponse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/localresponse.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/mcdonalds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/mcdonalds.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/muffle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/muffle.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/nextdays.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/nextdays.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/nimblequiz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/nimblequiz.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/nuorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/nuorder.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/scottyapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/scottyapp.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/seelio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/seelio.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/selectvids.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/selectvids.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/sharelatex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/sharelatex.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/shoejitsu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/shoejitsu.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/skim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/skim.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/squadsheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/squadsheet.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/stachify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/stachify.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/storify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/storify.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/todaylaunch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/todaylaunch.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/treinosmart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/treinosmart.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/upcload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/upcload.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/veriwalk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/veriwalk.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/wavo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/wavo.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/apps/zootify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/apps/zootify.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/images/square_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.3.x/docs/images/square_bg.png -------------------------------------------------------------------------------- /docs/3.3.x/docs/includes/googleanalytics.jade: -------------------------------------------------------------------------------- 1 | script. 2 | var _gaq = _gaq || []; 3 | _gaq.push(['_setAccount', 'UA-1122274-9']); 4 | _gaq.push(['_trackPageview']); 5 | 6 | (function() { 7 | var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 8 | ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 9 | var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); 10 | })(); 11 | -------------------------------------------------------------------------------- /docs/3.3.x/docs/includes/nav.jade: -------------------------------------------------------------------------------- 1 | ul 2 | li.home 3 | a(href="../index.html") home 4 | li.faq 5 | a(href="./faq.html") FAQ 6 | li.plugins 7 | a(href="http://plugins.mongoosejs.com") plugins 8 | li.changelog 9 | a(href="http://github.com/learnboost/mongoose/tree/master/History.md") change log 10 | li.support 11 | a(href="../index.html#support") support 12 | li.fork 13 | a(href="http://github.com/learnboost/mongoose") fork 14 | li.guide 15 | a(href="./guide.html") guide 16 | if (locals.guide) 17 | ul 18 | li.double 19 | a(href="./guide.html") schemas 20 | ul 21 | li.schematypes 22 | a(href="./schematypes.html") 23 | span schema 24 | | types 25 | li 26 | a(href="./models.html") models 27 | li.double 28 | a(href="./documents.html") documents 29 | ul 30 | li.subdocs 31 | a(href="./subdocs.html") sub docs 32 | li 33 | a(href="./queries.html") queries 34 | li 35 | a(href="./validation.html") validation 36 | li 37 | a(href="./middleware.html") middleware 38 | li 39 | a(href="./populate.html") population 40 | li 41 | a(href="./connections.html") connections 42 | li 43 | a(href="./plugins.html") plugins 44 | li 45 | a(href="https://github.com/LearnBoost/mongoose/blob/master/CONTRIBUTING.md") contributing 46 | li 47 | a(href="./migration.html") migrating from 2.x 48 | li.api 49 | a(href="./api.html") API docs 50 | li.quickstart 51 | a(href="./index.html") quick start 52 | li.contrib 53 | a(href="http://github.com/learnboost/mongoose/contributors") contributors 54 | li.prior 55 | a(href="./prior.html") prior releases 56 | -------------------------------------------------------------------------------- /docs/3.3.x/docs/js/cookies.min.js: -------------------------------------------------------------------------------- 1 | /*! Cookies.js - 0.2.0; Copyright (c) 2012, Scott Hamper; http://www.opensource.org/licenses/MIT */ 2 | (function(f,e){var b=function(c,d,a){return 1===arguments.length?b.get(c):b.set(c,d,a)};b.get=function(c){f.cookie!==b._cacheString&&b._populateCache();return b._cache[c]};b.defaults={path:"/"};b.set=function(c,d,a){a={path:a&&a.path||b.defaults.path,domain:a&&a.domain||b.defaults.domain,expires:a&&a.expires||b.defaults.expires,secure:a&&a.secure!==e?a.secure:b.defaults.secure};d===e&&(a.expires=-1);switch(typeof a.expires){case "number":a.expires=new Date((new Date).getTime()+1E3*a.expires);break; 3 | case "string":a.expires=new Date(a.expires)}c=encodeURIComponent(c)+"="+(d+"").replace(/[^!#-+\--:<-[\]-~]/g,encodeURIComponent);c+=a.path?";path="+a.path:"";c+=a.domain?";domain="+a.domain:"";c+=a.expires?";expires="+a.expires.toGMTString():"";c+=a.secure?";secure":"";f.cookie=c;return b};b.expire=function(c,d){return b.set(c,e,d)};b._populateCache=function(){b._cache={};b._cacheString=f.cookie;for(var c=b._cacheString.split("; "),d=0;d prev.mtime) { 26 | jadeify(filename, filemap[file]); 27 | } 28 | }); 29 | } 30 | }); 31 | 32 | function jadeify (filename, options) { 33 | options || (options = {}); 34 | options.package = package; 35 | options.hl = hl; 36 | options.linktype = linktype; 37 | options.href = href; 38 | options.klass = klass; 39 | jade.renderFile(filename, options, function (err, str) { 40 | if (err) return console.error(err.stack); 41 | 42 | var newfile = filename.replace('.jade', '.html') 43 | fs.writeFile(newfile, str, function (err) { 44 | if (err) return console.error('could not write', err.stack); 45 | console.log('%s : rendered ', new Date, newfile); 46 | }); 47 | }); 48 | } 49 | -------------------------------------------------------------------------------- /docs/3.3.x/static.js: -------------------------------------------------------------------------------- 1 | 2 | var static = require('node-static'); 3 | var server = new static.Server('.', { cache: 0 }); 4 | 5 | require('http').createServer(function (req, res) { 6 | req.on('end', function () { 7 | server.serve(req, res, function (err) { 8 | if (err) { 9 | console.error(err, req.url); 10 | res.writeHead(err.status, err.headers); 11 | res.end(); 12 | } 13 | }); 14 | }); 15 | }).listen(8088); 16 | 17 | console.error('now listening on localhost:8088'); 18 | -------------------------------------------------------------------------------- /docs/3.4.x/docs/helpers/filters.js: -------------------------------------------------------------------------------- 1 | 2 | var hl = require('highlight.js') 3 | 4 | module.exports = exports = function (jade) { 5 | // add highlighting filter to jade 6 | 7 | jade.filters.js = function (str) { 8 | str = str.replace(/\\n/g, '\n'); 9 | var ret = hl.highlight('javascript', str).value; 10 | var code = '
' + ret.replace(/\n/g, '\\n') + '
'; 11 | return code; 12 | } 13 | 14 | jade.filters.bash = function (str) { 15 | var ret = hl.highlight('bash', str.replace(/\\n/g, '\n')).value; 16 | var code = '
' + ret + '
'; 17 | return code 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /docs/3.4.x/docs/helpers/highlight.js: -------------------------------------------------------------------------------- 1 | 2 | var h = require('highlight.js') 3 | 4 | function hl (str) { 5 | str = str.replace(/\\n/g, '\n'); 6 | var ret = h.highlight('javascript', str).value; 7 | var code = '
' + ret+ '
'; 8 | return code; 9 | } 10 | 11 | module.exports = hl; 12 | -------------------------------------------------------------------------------- /docs/3.4.x/docs/helpers/href.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = exports = function (str, char) { 3 | if ('string' != typeof str) return str; 4 | return encodeURIComponent(str.replace(/\.js$/, '').replace(/\.|#/g, char || '-')); 5 | } 6 | -------------------------------------------------------------------------------- /docs/3.4.x/docs/helpers/klass.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = exports = function (str) { 3 | var parts = str.replace(/\.js$/, '').split('/'); 4 | return parts.join('_'); 5 | } 6 | -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/attictv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/attictv.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/bozuko.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/bozuko.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/calllist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/calllist.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/cldfy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/cldfy.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/clickdummy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/clickdummy.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/cyborgvision.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/cyborgvision.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/dashku.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/dashku.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/firstimpression.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/firstimpression.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/furbabyrescue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/furbabyrescue.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/geeklist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/geeklist.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/grab: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #make sure firefox launches in the bottom right corner of the window 4 | 5 | # read URLs from a data file in a loop 6 | #regex='([^[:space:]]+)[[:space:]]*(.*)' 7 | regex='([^[:space:]]+)[|]([^|]+)[|](.*)' 8 | 9 | func() { 10 | if [ -n "$2" ] 11 | then 12 | url=$1 13 | name=$2 14 | else 15 | [[ $1 =~ $regex ]] 16 | url=${BASH_REMATCH[1]} 17 | name=${BASH_REMATCH[2]} 18 | desc=${BASH_REMATCH[3]} 19 | fi 20 | 21 | # remove middle space, lowercase 22 | name=`echo $name | tr -d '[[:space:]]' | tr '[A-Z]' '[a-z]'` 23 | 24 | if [ -n "$name" ] 25 | then 26 | close_firefox 27 | 28 | # send URL to the firefox session 29 | # firefox --width 1030 --height 768 $url & 30 | /Applications/Firefox.app/Contents/MacOS/firefox --width 1030 --height 768 $url & 31 | echo started firefox with $url 32 | echo preparing screencapture ... 33 | 34 | # take a picture after waiting a bit for the load to finish 35 | sleep 6 36 | # gm import -window root -crop 1004x768+414+228 -resize 500x350 $name.png 37 | screencapture -wo $name.png 38 | gm convert $name.png -crop 1004x768+0+80 -resize 200x140 $name.png 39 | echo grabbed screenshot $name.png 40 | else 41 | echo missing name $1 $2 42 | fi 43 | } 44 | 45 | close_firefox() { 46 | if ps ax | grep -v grep | grep firefox > /dev/null 47 | then 48 | echo waiting for manual firefox shutdown... 49 | fi 50 | 51 | while true; do 52 | if ps ax | grep -v grep | grep firefox > /dev/null 53 | then 54 | sleep 1 55 | else 56 | break 57 | fi 58 | done 59 | echo firefox shutdown detected 60 | } 61 | 62 | if test -z "$1" 63 | then 64 | while read line 65 | do 66 | func $line 67 | done < urls 68 | else 69 | func $1 "$2" 70 | fi 71 | 72 | -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/growthegamegolf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/growthegamegolf.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/h_bozuko.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/h_bozuko.jpg -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/h_geeklist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/h_geeklist.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/h_learnboost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/h_learnboost.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/h_mcds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/h_mcds.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/h_shoejitsu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/h_shoejitsu.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/h_storify.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/h_storify.jpg -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/kyyti.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/kyyti.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/learnboost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/learnboost.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/linkr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/linkr.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/lists.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/lists.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/localresponse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/localresponse.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/mcdonalds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/mcdonalds.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/muffle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/muffle.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/nextdays.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/nextdays.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/nimblequiz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/nimblequiz.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/nuorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/nuorder.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/scottyapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/scottyapp.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/seelio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/seelio.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/selectvids.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/selectvids.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/sharelatex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/sharelatex.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/shoejitsu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/shoejitsu.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/skim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/skim.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/squadsheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/squadsheet.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/stachify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/stachify.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/storify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/storify.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/todaylaunch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/todaylaunch.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/treinosmart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/treinosmart.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/upcload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/upcload.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/veriwalk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/veriwalk.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/wavo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/wavo.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/apps/zootify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/apps/zootify.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/images/square_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.4.x/docs/images/square_bg.png -------------------------------------------------------------------------------- /docs/3.4.x/docs/includes/googleanalytics.jade: -------------------------------------------------------------------------------- 1 | script. 2 | var _gaq = _gaq || []; 3 | _gaq.push(['_setAccount', 'UA-1122274-9']); 4 | _gaq.push(['_trackPageview']); 5 | 6 | (function() { 7 | var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 8 | ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 9 | var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); 10 | })(); 11 | -------------------------------------------------------------------------------- /docs/3.4.x/docs/includes/nav.jade: -------------------------------------------------------------------------------- 1 | ul 2 | li.home 3 | a(href="../index.html") home 4 | li.faq 5 | a(href="./faq.html") FAQ 6 | li.plugins 7 | a(href="http://plugins.mongoosejs.com") plugins 8 | li.changelog 9 | a(href="http://github.com/learnboost/mongoose/tree/master/History.md") change log 10 | li.support 11 | a(href="../index.html#support") support 12 | li.fork 13 | a(href="http://github.com/learnboost/mongoose") fork 14 | li.guide 15 | a(href="./guide.html") guide 16 | if (locals.guide) 17 | ul 18 | li.double 19 | a(href="./guide.html") schemas 20 | ul 21 | li.schematypes 22 | a(href="./schematypes.html") 23 | span schema 24 | | types 25 | li 26 | a(href="./models.html") models 27 | li.double 28 | a(href="./documents.html") documents 29 | ul 30 | li.subdocs 31 | a(href="./subdocs.html") sub docs 32 | li 33 | a(href="./queries.html") queries 34 | li 35 | a(href="./validation.html") validation 36 | li 37 | a(href="./middleware.html") middleware 38 | li 39 | a(href="./populate.html") population 40 | li 41 | a(href="./connections.html") connections 42 | li 43 | a(href="./plugins.html") plugins 44 | li 45 | a(href="https://github.com/LearnBoost/mongoose/blob/master/CONTRIBUTING.md") contributing 46 | li 47 | a(href="./migration.html") migrating from 2.x 48 | li.api 49 | a(href="./api.html") API docs 50 | li.quickstart 51 | a(href="./index.html") quick start 52 | li.contrib 53 | a(href="http://github.com/learnboost/mongoose/contributors") contributors 54 | li.prior 55 | a(href="./prior.html") prior releases 56 | -------------------------------------------------------------------------------- /docs/3.4.x/docs/js/cookies.min.js: -------------------------------------------------------------------------------- 1 | /*! Cookies.js - 0.2.0; Copyright (c) 2012, Scott Hamper; http://www.opensource.org/licenses/MIT */ 2 | (function(f,e){var b=function(c,d,a){return 1===arguments.length?b.get(c):b.set(c,d,a)};b.get=function(c){f.cookie!==b._cacheString&&b._populateCache();return b._cache[c]};b.defaults={path:"/"};b.set=function(c,d,a){a={path:a&&a.path||b.defaults.path,domain:a&&a.domain||b.defaults.domain,expires:a&&a.expires||b.defaults.expires,secure:a&&a.secure!==e?a.secure:b.defaults.secure};d===e&&(a.expires=-1);switch(typeof a.expires){case "number":a.expires=new Date((new Date).getTime()+1E3*a.expires);break; 3 | case "string":a.expires=new Date(a.expires)}c=encodeURIComponent(c)+"="+(d+"").replace(/[^!#-+\--:<-[\]-~]/g,encodeURIComponent);c+=a.path?";path="+a.path:"";c+=a.domain?";domain="+a.domain:"";c+=a.expires?";expires="+a.expires.toGMTString():"";c+=a.secure?";secure":"";f.cookie=c;return b};b.expire=function(c,d){return b.set(c,e,d)};b._populateCache=function(){b._cache={};b._cacheString=f.cookie;for(var c=b._cacheString.split("; "),d=0;d prev.mtime) { 26 | jadeify(filename, filemap[file]); 27 | } 28 | }); 29 | } 30 | }); 31 | 32 | function jadeify (filename, options) { 33 | options || (options = {}); 34 | options.package = package; 35 | options.hl = hl; 36 | options.linktype = linktype; 37 | options.href = href; 38 | options.klass = klass; 39 | jade.renderFile(filename, options, function (err, str) { 40 | if (err) return console.error(err.stack); 41 | 42 | var newfile = filename.replace('.jade', '.html') 43 | fs.writeFile(newfile, str, function (err) { 44 | if (err) return console.error('could not write', err.stack); 45 | console.log('%s : rendered ', new Date, newfile); 46 | }); 47 | }); 48 | } 49 | -------------------------------------------------------------------------------- /docs/3.4.x/static.js: -------------------------------------------------------------------------------- 1 | 2 | var static = require('node-static'); 3 | var server = new static.Server('.', { cache: 0 }); 4 | 5 | require('http').createServer(function (req, res) { 6 | req.on('end', function () { 7 | server.serve(req, res, function (err) { 8 | if (err) { 9 | console.error(err, req.url); 10 | res.writeHead(err.status, err.headers); 11 | res.end(); 12 | } 13 | }); 14 | }); 15 | }).listen(8088); 16 | 17 | console.error('now listening on localhost:8088'); 18 | -------------------------------------------------------------------------------- /docs/3.5.x/docs/helpers/filters.js: -------------------------------------------------------------------------------- 1 | 2 | var hl = require('highlight.js') 3 | 4 | module.exports = exports = function (jade) { 5 | // add highlighting filter to jade 6 | 7 | jade.filters.js = function (str) { 8 | str = str.replace(/\\n/g, '\n'); 9 | var ret = hl.highlight('javascript', str).value; 10 | var code = '
' + ret.replace(/\n/g, '\\n') + '
'; 11 | return code; 12 | } 13 | 14 | jade.filters.bash = function (str) { 15 | var ret = hl.highlight('bash', str.replace(/\\n/g, '\n')).value; 16 | var code = '
' + ret + '
'; 17 | return code 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /docs/3.5.x/docs/helpers/highlight.js: -------------------------------------------------------------------------------- 1 | 2 | var h = require('highlight.js') 3 | 4 | function hl (str) { 5 | str = str.replace(/\\n/g, '\n'); 6 | var ret = h.highlight('javascript', str).value; 7 | var code = '
' + ret+ '
'; 8 | return code; 9 | } 10 | 11 | module.exports = hl; 12 | -------------------------------------------------------------------------------- /docs/3.5.x/docs/helpers/href.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = exports = function (str, char) { 3 | if ('string' != typeof str) return str; 4 | return encodeURIComponent( 5 | str.replace(/\.js$/, '') 6 | .replace(/#/g, char || '-') 7 | ); 8 | } 9 | -------------------------------------------------------------------------------- /docs/3.5.x/docs/helpers/klass.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = exports = function (str) { 3 | var parts = str.replace(/\.js$/, '').split('/'); 4 | return parts.join('_'); 5 | } 6 | -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/attictv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/attictv.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/bozuko.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/bozuko.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/calllist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/calllist.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/cldfy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/cldfy.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/clickdummy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/clickdummy.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/cyborgvision.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/cyborgvision.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/dashku.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/dashku.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/firstimpression.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/firstimpression.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/furbabyrescue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/furbabyrescue.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/geeklist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/geeklist.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/grab: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #make sure firefox launches in the bottom right corner of the window 4 | 5 | # read URLs from a data file in a loop 6 | #regex='([^[:space:]]+)[[:space:]]*(.*)' 7 | regex='([^[:space:]]+)[|]([^|]+)[|](.*)' 8 | 9 | func() { 10 | if [ -n "$2" ] 11 | then 12 | url=$1 13 | name=$2 14 | else 15 | [[ $1 =~ $regex ]] 16 | url=${BASH_REMATCH[1]} 17 | name=${BASH_REMATCH[2]} 18 | desc=${BASH_REMATCH[3]} 19 | fi 20 | 21 | # remove middle space, lowercase 22 | name=`echo $name | tr -d '[[:space:]]' | tr '[A-Z]' '[a-z]'` 23 | 24 | if [ -n "$name" ] 25 | then 26 | close_firefox 27 | 28 | # send URL to the firefox session 29 | # firefox --width 1030 --height 768 $url & 30 | /Applications/Firefox.app/Contents/MacOS/firefox --width 1030 --height 768 $url & 31 | echo started firefox with $url 32 | echo preparing screencapture ... 33 | 34 | # take a picture after waiting a bit for the load to finish 35 | sleep 6 36 | # gm import -window root -crop 1004x768+414+228 -resize 500x350 $name.png 37 | screencapture -wo $name.png 38 | gm convert $name.png -crop 1004x768+0+80 -resize 200x140 $name.png 39 | echo grabbed screenshot $name.png 40 | else 41 | echo missing name $1 $2 42 | fi 43 | } 44 | 45 | close_firefox() { 46 | if ps ax | grep -v grep | grep firefox > /dev/null 47 | then 48 | echo waiting for manual firefox shutdown... 49 | fi 50 | 51 | while true; do 52 | if ps ax | grep -v grep | grep firefox > /dev/null 53 | then 54 | sleep 1 55 | else 56 | break 57 | fi 58 | done 59 | echo firefox shutdown detected 60 | } 61 | 62 | if test -z "$1" 63 | then 64 | while read line 65 | do 66 | func $line 67 | done < urls 68 | else 69 | func $1 "$2" 70 | fi 71 | 72 | -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/growthegamegolf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/growthegamegolf.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/h_bozuko.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/h_bozuko.jpg -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/h_geeklist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/h_geeklist.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/h_learnboost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/h_learnboost.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/h_mcds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/h_mcds.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/h_shoejitsu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/h_shoejitsu.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/h_storify.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/h_storify.jpg -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/knack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/knack.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/kyyti.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/kyyti.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/learnboost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/learnboost.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/linkr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/linkr.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/lists.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/lists.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/localresponse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/localresponse.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/mcdonalds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/mcdonalds.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/moveline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/moveline.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/muffle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/muffle.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/mybrickbuilds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/mybrickbuilds.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/nextdays.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/nextdays.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/nimblequiz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/nimblequiz.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/nuorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/nuorder.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/panemerkille.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/panemerkille.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/pictorious.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/pictorious.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/scottyapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/scottyapp.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/seelio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/seelio.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/selectvids.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/selectvids.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/sharelatex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/sharelatex.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/shoejitsu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/shoejitsu.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/skim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/skim.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/squadsheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/squadsheet.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/stachify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/stachify.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/storify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/storify.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/todaylaunch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/todaylaunch.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/treinosmart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/treinosmart.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/upcload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/upcload.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/veriwalk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/veriwalk.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/wavo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/wavo.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/apps/zootify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/apps/zootify.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/images/square_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/3.5.x/docs/images/square_bg.png -------------------------------------------------------------------------------- /docs/3.5.x/docs/includes/googleanalytics.jade: -------------------------------------------------------------------------------- 1 | script. 2 | var _gaq = _gaq || []; 3 | _gaq.push(['_setAccount', 'UA-1122274-9']); 4 | _gaq.push(['_trackPageview', location.pathname + location.search + location.hash]); 5 | 6 | (function() { 7 | var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 8 | ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 9 | var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); 10 | })(); 11 | -------------------------------------------------------------------------------- /docs/3.5.x/docs/includes/nav.jade: -------------------------------------------------------------------------------- 1 | ul 2 | li.home 3 | a(href="../index.html") home 4 | li.faq 5 | a(href="./faq.html") FAQ 6 | li.plugins 7 | a(href="http://plugins.mongoosejs.com") plugins 8 | li.changelog 9 | a(href="http://github.com/learnboost/mongoose/tree/master/History.md") change log 10 | li.support 11 | a(href="../index.html#support") support 12 | li.fork 13 | a(href="http://github.com/learnboost/mongoose") fork 14 | li.guide 15 | a(href="./guide.html") guide 16 | if (locals.guide) 17 | ul 18 | li.double 19 | a(href="./guide.html") schemas 20 | ul 21 | li.schematypes 22 | a(href="./schematypes.html") 23 | span schema 24 | | types 25 | li 26 | a(href="./models.html") models 27 | li.double 28 | a(href="./documents.html") documents 29 | ul 30 | li.subdocs 31 | a(href="./subdocs.html") sub docs 32 | li 33 | a(href="./queries.html") queries 34 | li 35 | a(href="./validation.html") validation 36 | li 37 | a(href="./middleware.html") middleware 38 | li 39 | a(href="./populate.html") population 40 | li 41 | a(href="./connections.html") connections 42 | li 43 | a(href="./plugins.html") plugins 44 | li 45 | a(href="https://github.com/LearnBoost/mongoose/blob/master/CONTRIBUTING.md") contributing 46 | li 47 | a(href="./migration.html") migrating from 2.x 48 | li.api 49 | a(href="./api.html") API docs 50 | li.quickstart 51 | a(href="./index.html") quick start 52 | li.contrib 53 | a(href="http://github.com/learnboost/mongoose/contributors") contributors 54 | li.prior 55 | a(href="./prior.html") prior releases 56 | -------------------------------------------------------------------------------- /docs/3.5.x/docs/js/cookies.min.js: -------------------------------------------------------------------------------- 1 | /*! Cookies.js - 0.2.0; Copyright (c) 2012, Scott Hamper; http://www.opensource.org/licenses/MIT */ 2 | (function(f,e){var b=function(c,d,a){return 1===arguments.length?b.get(c):b.set(c,d,a)};b.get=function(c){f.cookie!==b._cacheString&&b._populateCache();return b._cache[c]};b.defaults={path:"/"};b.set=function(c,d,a){a={path:a&&a.path||b.defaults.path,domain:a&&a.domain||b.defaults.domain,expires:a&&a.expires||b.defaults.expires,secure:a&&a.secure!==e?a.secure:b.defaults.secure};d===e&&(a.expires=-1);switch(typeof a.expires){case "number":a.expires=new Date((new Date).getTime()+1E3*a.expires);break; 3 | case "string":a.expires=new Date(a.expires)}c=encodeURIComponent(c)+"="+(d+"").replace(/[^!#-+\--:<-[\]-~]/g,encodeURIComponent);c+=a.path?";path="+a.path:"";c+=a.domain?";domain="+a.domain:"";c+=a.expires?";expires="+a.expires.toGMTString():"";c+=a.secure?";secure":"";f.cookie=c;return b};b.expire=function(c,d){return b.set(c,e,d)};b._populateCache=function(){b._cache={};b._cacheString=f.cookie;for(var c=b._cacheString.split("; "),d=0;d'; 11 | return code; 12 | } 13 | 14 | jade.filters.bash = function (str) { 15 | var ret = hl.highlight('bash', str.replace(/\\n/g, '\n')).value; 16 | var code = '
' + ret + '
'; 17 | return code 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /docs/helpers/highlight.js: -------------------------------------------------------------------------------- 1 | 2 | var h = require('highlight.js') 3 | 4 | function hl (str) { 5 | str = str.replace(/\\n/g, '\n'); 6 | var ret = h.highlight('javascript', str).value; 7 | var code = '
' + ret+ '
'; 8 | return code; 9 | } 10 | 11 | module.exports = hl; 12 | -------------------------------------------------------------------------------- /docs/helpers/href.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = exports = function (str, char) { 3 | if ('string' != typeof str) return str; 4 | return encodeURIComponent( 5 | str.replace(/\.js$/, '') 6 | .replace(/#/g, char || '-') 7 | ); 8 | } 9 | -------------------------------------------------------------------------------- /docs/helpers/klass.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = exports = function (str) { 3 | var parts = str.replace(/\.js$/, '').split('/'); 4 | return parts.join('_'); 5 | } 6 | -------------------------------------------------------------------------------- /docs/images/apps/attictv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/attictv.png -------------------------------------------------------------------------------- /docs/images/apps/bozuko.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/bozuko.png -------------------------------------------------------------------------------- /docs/images/apps/calllist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/calllist.png -------------------------------------------------------------------------------- /docs/images/apps/cldfy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/cldfy.png -------------------------------------------------------------------------------- /docs/images/apps/clickdummy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/clickdummy.png -------------------------------------------------------------------------------- /docs/images/apps/cyborgvision.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/cyborgvision.png -------------------------------------------------------------------------------- /docs/images/apps/dashku.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/dashku.png -------------------------------------------------------------------------------- /docs/images/apps/firstimpression.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/firstimpression.png -------------------------------------------------------------------------------- /docs/images/apps/furbabyrescue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/furbabyrescue.png -------------------------------------------------------------------------------- /docs/images/apps/geeklist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/geeklist.png -------------------------------------------------------------------------------- /docs/images/apps/grab: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #make sure firefox launches in the bottom right corner of the window 4 | 5 | # read URLs from a data file in a loop 6 | #regex='([^[:space:]]+)[[:space:]]*(.*)' 7 | regex='([^[:space:]]+)[|]([^|]+)[|](.*)' 8 | 9 | func() { 10 | if [ -n "$2" ] 11 | then 12 | url=$1 13 | name=$2 14 | else 15 | [[ $1 =~ $regex ]] 16 | url=${BASH_REMATCH[1]} 17 | name=${BASH_REMATCH[2]} 18 | desc=${BASH_REMATCH[3]} 19 | fi 20 | 21 | # remove middle space, lowercase 22 | name=`echo $name | tr -d '[[:space:]]' | tr '[A-Z]' '[a-z]'` 23 | 24 | if [ -n "$name" ] 25 | then 26 | close_firefox 27 | 28 | # send URL to the firefox session 29 | # firefox --width 1030 --height 768 $url & 30 | /Applications/Firefox.app/Contents/MacOS/firefox --width 1030 --height 768 $url & 31 | echo started firefox with $url 32 | echo preparing screencapture ... 33 | 34 | # take a picture after waiting a bit for the load to finish 35 | sleep 6 36 | # gm import -window root -crop 1004x768+414+228 -resize 500x350 $name.png 37 | screencapture -wo $name.png 38 | gm convert $name.png -crop 1004x768+0+80 -resize 200x140 $name.png 39 | echo grabbed screenshot $name.png 40 | else 41 | echo missing name $1 $2 42 | fi 43 | } 44 | 45 | close_firefox() { 46 | if ps ax | grep -v grep | grep firefox > /dev/null 47 | then 48 | echo waiting for manual firefox shutdown... 49 | fi 50 | 51 | while true; do 52 | if ps ax | grep -v grep | grep firefox > /dev/null 53 | then 54 | sleep 1 55 | else 56 | break 57 | fi 58 | done 59 | echo firefox shutdown detected 60 | } 61 | 62 | if test -z "$1" 63 | then 64 | while read line 65 | do 66 | func $line 67 | done < urls 68 | else 69 | func $1 "$2" 70 | fi 71 | 72 | -------------------------------------------------------------------------------- /docs/images/apps/growthegamegolf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/growthegamegolf.png -------------------------------------------------------------------------------- /docs/images/apps/h_bozuko.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/h_bozuko.jpg -------------------------------------------------------------------------------- /docs/images/apps/h_geeklist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/h_geeklist.png -------------------------------------------------------------------------------- /docs/images/apps/h_learnboost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/h_learnboost.png -------------------------------------------------------------------------------- /docs/images/apps/h_mcds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/h_mcds.png -------------------------------------------------------------------------------- /docs/images/apps/h_shoejitsu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/h_shoejitsu.png -------------------------------------------------------------------------------- /docs/images/apps/h_storify.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/h_storify.jpg -------------------------------------------------------------------------------- /docs/images/apps/knack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/knack.png -------------------------------------------------------------------------------- /docs/images/apps/kyyti.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/kyyti.png -------------------------------------------------------------------------------- /docs/images/apps/learnboost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/learnboost.png -------------------------------------------------------------------------------- /docs/images/apps/linkr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/linkr.png -------------------------------------------------------------------------------- /docs/images/apps/lists.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/lists.png -------------------------------------------------------------------------------- /docs/images/apps/localresponse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/localresponse.png -------------------------------------------------------------------------------- /docs/images/apps/mcdonalds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/mcdonalds.png -------------------------------------------------------------------------------- /docs/images/apps/moveline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/moveline.png -------------------------------------------------------------------------------- /docs/images/apps/muffle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/muffle.png -------------------------------------------------------------------------------- /docs/images/apps/mybrickbuilds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/mybrickbuilds.png -------------------------------------------------------------------------------- /docs/images/apps/nextdays.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/nextdays.png -------------------------------------------------------------------------------- /docs/images/apps/nimblequiz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/nimblequiz.png -------------------------------------------------------------------------------- /docs/images/apps/nuorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/nuorder.png -------------------------------------------------------------------------------- /docs/images/apps/panemerkille.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/panemerkille.png -------------------------------------------------------------------------------- /docs/images/apps/pictorious.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/pictorious.png -------------------------------------------------------------------------------- /docs/images/apps/scottyapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/scottyapp.png -------------------------------------------------------------------------------- /docs/images/apps/seelio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/seelio.png -------------------------------------------------------------------------------- /docs/images/apps/selectvids.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/selectvids.png -------------------------------------------------------------------------------- /docs/images/apps/sharelatex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/sharelatex.png -------------------------------------------------------------------------------- /docs/images/apps/shoejitsu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/shoejitsu.png -------------------------------------------------------------------------------- /docs/images/apps/skim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/skim.png -------------------------------------------------------------------------------- /docs/images/apps/squadsheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/squadsheet.png -------------------------------------------------------------------------------- /docs/images/apps/stachify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/stachify.png -------------------------------------------------------------------------------- /docs/images/apps/storify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/storify.png -------------------------------------------------------------------------------- /docs/images/apps/todaylaunch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/todaylaunch.png -------------------------------------------------------------------------------- /docs/images/apps/treinosmart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/treinosmart.png -------------------------------------------------------------------------------- /docs/images/apps/upcload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/upcload.png -------------------------------------------------------------------------------- /docs/images/apps/veriwalk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/veriwalk.png -------------------------------------------------------------------------------- /docs/images/apps/wavo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/wavo.png -------------------------------------------------------------------------------- /docs/images/apps/zootify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/apps/zootify.png -------------------------------------------------------------------------------- /docs/images/square_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/docs/images/square_bg.png -------------------------------------------------------------------------------- /docs/includes/googleanalytics.jade: -------------------------------------------------------------------------------- 1 | script. 2 | var _gaq = _gaq || []; 3 | _gaq.push(['_setAccount', 'UA-1122274-9']); 4 | _gaq.push(['_trackPageview', location.pathname + location.search + location.hash]); 5 | 6 | (function() { 7 | var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 8 | ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 9 | var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); 10 | })(); 11 | -------------------------------------------------------------------------------- /docs/includes/googlesearch.jade: -------------------------------------------------------------------------------- 1 | script 2 | ;(function() { 3 | var cx = '012173159455227967368:uvscsuqjovs'; 4 | var gcse = document.createElement('script'); 5 | gcse.type = 'text/javascript'; 6 | gcse.async = true; 7 | gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + 8 | '//www.google.com/cse/cse.js?cx=' + cx; 9 | var s = document.getElementsByTagName('script')[0]; 10 | s.parentNode.insertBefore(gcse, s); 11 | })(); 12 | -------------------------------------------------------------------------------- /docs/js/cookies.min.js: -------------------------------------------------------------------------------- 1 | /*! Cookies.js - 0.2.0; Copyright (c) 2012, Scott Hamper; http://www.opensource.org/licenses/MIT */ 2 | (function(f,e){var b=function(c,d,a){return 1===arguments.length?b.get(c):b.set(c,d,a)};b.get=function(c){f.cookie!==b._cacheString&&b._populateCache();return b._cache[c]};b.defaults={path:"/"};b.set=function(c,d,a){a={path:a&&a.path||b.defaults.path,domain:a&&a.domain||b.defaults.domain,expires:a&&a.expires||b.defaults.expires,secure:a&&a.secure!==e?a.secure:b.defaults.secure};d===e&&(a.expires=-1);switch(typeof a.expires){case "number":a.expires=new Date((new Date).getTime()+1E3*a.expires);break; 3 | case "string":a.expires=new Date(a.expires)}c=encodeURIComponent(c)+"="+(d+"").replace(/[^!#-+\--:<-[\]-~]/g,encodeURIComponent);c+=a.path?";path="+a.path:"";c+=a.domain?";domain="+a.domain:"";c+=a.expires?";expires="+a.expires.toGMTString():"";c+=a.secure?";secure":"";f.cookie=c;return b};b.expire=function(c,d){return b.set(c,e,d)};b._populateCache=function(){b._cache={};b._cacheString=f.cookie;for(var c=b._cacheString.split("; "),d=0;d prev.mtime) { 26 | jadeify(filename, filemap[file]); 27 | } 28 | }); 29 | } 30 | }); 31 | 32 | function jadeify (filename, options) { 33 | options || (options = {}); 34 | options.package = package; 35 | options.hl = hl; 36 | options.linktype = linktype; 37 | options.href = href; 38 | options.klass = klass; 39 | jade.renderFile(filename, options, function (err, str) { 40 | if (err) return console.error(err.stack); 41 | 42 | var newfile = filename.replace('.jade', '.html') 43 | fs.writeFile(newfile, str, function (err) { 44 | if (err) return console.error('could not write', err.stack); 45 | console.log('%s : rendered ', new Date, newfile); 46 | }); 47 | }); 48 | } 49 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | This directory contains runnable sample mongoose programs. 2 | 3 | To run: 4 | 5 | - first install [Node.js](http://nodejs.org/) 6 | - from the root of the project, execute `npm install -d` 7 | - in the example directory, run `npm install -d` 8 | - from the command line, execute: `node example.js`, replacing "example.js" with the name of a program. 9 | 10 | 11 | Goal is to show: 12 | 13 | - ~~global schemas~~ 14 | - ~~GeoJSON schemas / use (with crs)~~ 15 | - text search (once MongoDB removes the "Experimental/beta" label) 16 | - ~~lean queries~~ 17 | - ~~statics~~ 18 | - methods and statics on subdocs 19 | - custom types 20 | - ~~querybuilder~~ 21 | - ~~promises~~ 22 | - accessing driver collection, db 23 | - ~~connecting to replica sets~~ 24 | - connecting to sharded clusters 25 | - enabling a fail fast mode 26 | - on the fly schemas 27 | - storing files 28 | - ~~map reduce~~ 29 | - ~~aggregation~~ 30 | - advanced hooks 31 | - using $elemMatch to return a subset of an array 32 | - query casting 33 | - upserts 34 | - pagination 35 | - express + mongoose session handling 36 | - ~~group by (use aggregation)~~ 37 | - authentication 38 | - schema migration techniques 39 | - converting documents to plain objects (show transforms) 40 | - how to $unset 41 | 42 | -------------------------------------------------------------------------------- /examples/aggregate/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aggregate-example", 3 | "private": "true", 4 | "version": "0.0.0", 5 | "description": "deps for aggregate example", 6 | "main": "aggregate.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "dependencies": { "async": "*" }, 11 | "repository": "", 12 | "author": "", 13 | "license": "BSD" 14 | } 15 | -------------------------------------------------------------------------------- /examples/aggregate/person.js: -------------------------------------------------------------------------------- 1 | 2 | // import the necessary modules 3 | var mongoose = require('../../lib'); 4 | var Schema = mongoose.Schema; 5 | 6 | // create an export function to encapsulate the model creation 7 | module.exports = function() { 8 | // define schema 9 | var PersonSchema = new Schema({ 10 | name : String, 11 | age : Number, 12 | birthday : Date, 13 | gender: String, 14 | likes: [String] 15 | }); 16 | mongoose.model('Person', PersonSchema); 17 | }; 18 | -------------------------------------------------------------------------------- /examples/doc-methods.js: -------------------------------------------------------------------------------- 1 | 2 | var mongoose = require('mongoose') 3 | var Schema = mongoose.Schema; 4 | 5 | console.log('Running mongoose version %s', mongoose.version); 6 | 7 | /** 8 | * Schema 9 | */ 10 | 11 | var CharacterSchema = Schema({ 12 | name: { type: String, required: true } 13 | , health: { type: Number, min: 0, max: 100 } 14 | }) 15 | 16 | /** 17 | * Methods 18 | */ 19 | 20 | CharacterSchema.methods.attack = function () { 21 | console.log('%s is attacking', this.name); 22 | } 23 | 24 | /** 25 | * Character model 26 | */ 27 | 28 | var Character = mongoose.model('Character', CharacterSchema); 29 | 30 | /** 31 | * Connect to the database on localhost with 32 | * the default port (27017) 33 | */ 34 | 35 | var dbname = 'mongoose-example-doc-methods-' + ((Math.random()*10000)|0); 36 | var uri = 'mongodb://localhost/' + dbname; 37 | 38 | console.log('connecting to %s', uri); 39 | 40 | mongoose.connect(uri, function (err) { 41 | // if we failed to connect, abort 42 | if (err) throw err; 43 | 44 | // we connected ok 45 | example(); 46 | }) 47 | 48 | /** 49 | * Use case 50 | */ 51 | 52 | function example () { 53 | Character.create({ name: 'Link', health: 100 }, function (err, link) { 54 | if (err) return done(err); 55 | console.log('found', link); 56 | link.attack(); // 'Link is attacking' 57 | done(); 58 | }) 59 | } 60 | 61 | /** 62 | * Clean up 63 | */ 64 | 65 | function done (err) { 66 | if (err) console.error(err); 67 | mongoose.connection.db.dropDatabase(function () { 68 | mongoose.disconnect(); 69 | }) 70 | } 71 | -------------------------------------------------------------------------------- /examples/express/README.md: -------------------------------------------------------------------------------- 1 | Mongoose + Express examples 2 | -------------------------------------------------------------------------------- /examples/express/connection-sharing/README.md: -------------------------------------------------------------------------------- 1 | 2 | To run: 3 | 4 | - Execute `npm install` from this directory 5 | - Execute `node app.js` 6 | - Navigate to `localhost:8000` 7 | -------------------------------------------------------------------------------- /examples/express/connection-sharing/app.js: -------------------------------------------------------------------------------- 1 | 2 | var express = require('express') 3 | var mongoose = require('../../../lib') 4 | 5 | var uri = 'mongodb://localhost/mongoose-shared-connection'; 6 | global.db = mongoose.createConnection(uri); 7 | 8 | var routes = require('./routes') 9 | 10 | var app = express(); 11 | app.get('/', routes.home); 12 | app.get('/insert', routes.insert); 13 | app.get('/name', routes.modelName); 14 | 15 | app.listen(8000, function () { 16 | console.log('listening on http://localhost:8000'); 17 | }) 18 | 19 | -------------------------------------------------------------------------------- /examples/express/connection-sharing/modelA.js: -------------------------------------------------------------------------------- 1 | 2 | var Schema = require('../../../lib').Schema; 3 | var mySchema = Schema({ name: String }); 4 | 5 | // db is global 6 | module.exports = db.model('MyModel', mySchema); 7 | -------------------------------------------------------------------------------- /examples/express/connection-sharing/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "connection-sharing", 3 | "private": "true", 4 | "version": "0.0.0", 5 | "description": "ERROR: No README.md file found!", 6 | "main": "app.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "dependencies": { "express": "3.1.1" }, 11 | "repository": "", 12 | "author": "", 13 | "license": "BSD" 14 | } 15 | -------------------------------------------------------------------------------- /examples/express/connection-sharing/routes.js: -------------------------------------------------------------------------------- 1 | 2 | var model = require('./modelA') 3 | 4 | exports.home = function (req, res, next) { 5 | model.find(function (err, docs) { 6 | if (err) return next(err); 7 | res.send(docs); 8 | }) 9 | } 10 | 11 | exports.modelName = function (req, res) { 12 | res.send('my model name is ' + model.modelName); 13 | } 14 | 15 | exports.insert = function (req, res, next) { 16 | model.create({ name: 'inserting ' + Date.now() }, function (err, doc) { 17 | if (err) return next(err); 18 | res.send(doc); 19 | }) 20 | } 21 | -------------------------------------------------------------------------------- /examples/geospatial/geoJSONSchema.js: -------------------------------------------------------------------------------- 1 | 2 | // import the necessary modules 3 | var mongoose = require('../../lib'); 4 | var Schema = mongoose.Schema; 5 | 6 | // create an export function to encapsulate the model creation 7 | module.exports = function() { 8 | // define schema 9 | // NOTE : This object must conform *precisely* to the geoJSON specification 10 | // you cannot embed a geoJSON doc inside a model or anything like that- IT 11 | // MUST BE VANILLA 12 | var LocationObject = new Schema({ 13 | loc: { 14 | type: { type: String }, 15 | coordinates: [] 16 | } 17 | }); 18 | // define the index 19 | LocationObject.index({ loc : '2dsphere' }); 20 | 21 | mongoose.model('Location', LocationObject); 22 | }; 23 | -------------------------------------------------------------------------------- /examples/geospatial/geoJSONexample.js: -------------------------------------------------------------------------------- 1 | 2 | // import async to make control flow simplier 3 | var async = require('async'); 4 | 5 | // import the rest of the normal stuff 6 | var mongoose = require('../../lib'); 7 | 8 | require('./geoJSONSchema.js')(); 9 | 10 | var Location = mongoose.model('Location'); 11 | 12 | // define some dummy data 13 | // note: the type can be Point, LineString, or Polygon 14 | var data = [ 15 | { loc: { type: 'Point', coordinates: [-20.0, 5.0] }}, 16 | { loc: { type: 'Point', coordinates: [6.0, 10.0] }}, 17 | { loc: { type: 'Point', coordinates: [34.0, -50.0] }}, 18 | { loc: { type: 'Point', coordinates: [-100.0, 70.0] }}, 19 | { loc: { type: 'Point', coordinates: [38.0, 38.0] }} 20 | ]; 21 | 22 | 23 | mongoose.connect('mongodb://localhost/locations', function (err) { 24 | if (err) throw err; 25 | 26 | Location.on('index', function(err) { 27 | if (err) throw err; 28 | // create all of the dummy locations 29 | async.each(data, function (item, cb) { 30 | Location.create(item, cb); 31 | }, function (err) { 32 | if (err) throw err; 33 | // create the location we want to search for 34 | var coords = { type : 'Point', coordinates : [-5, 5] }; 35 | // search for it 36 | Location.find({ loc : { $near : coords }}).limit(1).exec(function(err, res) { 37 | if (err) throw err; 38 | console.log("Closest to %s is %s", JSON.stringify(coords), res); 39 | cleanup(); 40 | }); 41 | }); 42 | }); 43 | }); 44 | 45 | function cleanup() { 46 | Location.remove(function() { 47 | mongoose.disconnect(); 48 | }); 49 | } 50 | -------------------------------------------------------------------------------- /examples/geospatial/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "geospatial-example", 3 | "private": "true", 4 | "version": "0.0.0", 5 | "description": "deps for geospatial example", 6 | "main": "geospatial.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "dependencies": { "async": "*" }, 11 | "repository": "", 12 | "author": "", 13 | "license": "BSD" 14 | } 15 | -------------------------------------------------------------------------------- /examples/geospatial/person.js: -------------------------------------------------------------------------------- 1 | 2 | // import the necessary modules 3 | var mongoose = require('../../lib'); 4 | var Schema = mongoose.Schema; 5 | 6 | // create an export function to encapsulate the model creation 7 | module.exports = function() { 8 | // define schema 9 | var PersonSchema = new Schema({ 10 | name : String, 11 | age : Number, 12 | birthday : Date, 13 | gender: String, 14 | likes: [String], 15 | // define the geospatial field 16 | loc: { type : [Number], index: '2d' } 17 | }); 18 | 19 | // define a method to find the closest person 20 | PersonSchema.methods.findClosest = function(cb) { 21 | return this.model('Person').find({ 22 | loc : { $nearSphere : this.loc }, 23 | name : { $ne : this.name } 24 | }).limit(1).exec(cb); 25 | }; 26 | 27 | mongoose.model('Person', PersonSchema); 28 | }; 29 | -------------------------------------------------------------------------------- /examples/globalschemas/gs_example.js: -------------------------------------------------------------------------------- 1 | 2 | var mongoose = require('../../lib'); 3 | 4 | 5 | // import the global schema, this can be done in any file that needs the model 6 | require('./person.js')(); 7 | 8 | // grab the person model object 9 | var Person = mongoose.model("Person"); 10 | 11 | // connect to a server to do a quick write / read example 12 | 13 | mongoose.connect('mongodb://localhost/persons', function(err) { 14 | if (err) throw err; 15 | 16 | Person.create({ 17 | name : 'bill', 18 | age : 25, 19 | birthday : new Date().setFullYear((new Date().getFullYear() - 25)) 20 | }, function (err, bill) { 21 | if (err) throw err; 22 | console.log("People added to db: %s", bill.toString()); 23 | Person.find({}, function(err, people) { 24 | if (err) throw err; 25 | 26 | people.forEach(function(person) { 27 | console.log("People in the db: %s", person.toString()); 28 | }); 29 | 30 | // make sure to clean things up after we're done 31 | setTimeout(function () { cleanup(); }, 2000); 32 | }); 33 | }); 34 | }); 35 | 36 | function cleanup() { 37 | Person.remove(function() { 38 | mongoose.disconnect(); 39 | }); 40 | } 41 | -------------------------------------------------------------------------------- /examples/globalschemas/person.js: -------------------------------------------------------------------------------- 1 | 2 | // import the necessary modules 3 | var mongoose = require('../../lib'); 4 | var Schema = mongoose.Schema; 5 | 6 | // create an export function to encapsulate the model creation 7 | module.exports = function() { 8 | // define schema 9 | var PersonSchema = new Schema({ 10 | name : String, 11 | age : Number, 12 | birthday : Date 13 | }); 14 | mongoose.model('Person', PersonSchema); 15 | }; 16 | -------------------------------------------------------------------------------- /examples/lean/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lean-example", 3 | "private": "true", 4 | "version": "0.0.0", 5 | "description": "deps for lean example", 6 | "main": "lean.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "dependencies": { "async": "*" }, 11 | "repository": "", 12 | "author": "", 13 | "license": "BSD" 14 | } 15 | -------------------------------------------------------------------------------- /examples/lean/person.js: -------------------------------------------------------------------------------- 1 | 2 | // import the necessary modules 3 | var mongoose = require('../../lib'); 4 | var Schema = mongoose.Schema; 5 | 6 | // create an export function to encapsulate the model creation 7 | module.exports = function() { 8 | // define schema 9 | var PersonSchema = new Schema({ 10 | name : String, 11 | age : Number, 12 | birthday : Date, 13 | gender: String, 14 | likes: [String] 15 | }); 16 | mongoose.model('Person', PersonSchema); 17 | }; 18 | -------------------------------------------------------------------------------- /examples/mapreduce/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "map-reduce-example", 3 | "private": "true", 4 | "version": "0.0.0", 5 | "description": "deps for map reduce example", 6 | "main": "mapreduce.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "dependencies": { "async": "*" }, 11 | "repository": "", 12 | "author": "", 13 | "license": "BSD" 14 | } 15 | -------------------------------------------------------------------------------- /examples/mapreduce/person.js: -------------------------------------------------------------------------------- 1 | 2 | // import the necessary modules 3 | var mongoose = require('../../lib'); 4 | var Schema = mongoose.Schema; 5 | 6 | // create an export function to encapsulate the model creation 7 | module.exports = function() { 8 | // define schema 9 | var PersonSchema = new Schema({ 10 | name : String, 11 | age : Number, 12 | birthday : Date, 13 | gender: String 14 | }); 15 | mongoose.model('Person', PersonSchema); 16 | }; 17 | -------------------------------------------------------------------------------- /examples/promises/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "promise-example", 3 | "private": "true", 4 | "version": "0.0.0", 5 | "description": "deps for promise example", 6 | "main": "promise.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "dependencies": { "async": "*" }, 11 | "repository": "", 12 | "author": "", 13 | "license": "BSD" 14 | } 15 | -------------------------------------------------------------------------------- /examples/promises/person.js: -------------------------------------------------------------------------------- 1 | 2 | // import the necessary modules 3 | var mongoose = require('../../lib'); 4 | var Schema = mongoose.Schema; 5 | 6 | // create an export function to encapsulate the model creation 7 | module.exports = function() { 8 | // define schema 9 | var PersonSchema = new Schema({ 10 | name : String, 11 | age : Number, 12 | birthday : Date 13 | }); 14 | mongoose.model('Person', PersonSchema); 15 | }; 16 | -------------------------------------------------------------------------------- /examples/querybuilder/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "query-builder-example", 3 | "private": "true", 4 | "version": "0.0.0", 5 | "description": "deps for query builder example", 6 | "main": "querybuilder.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "dependencies": { "async": "*" }, 11 | "repository": "", 12 | "author": "", 13 | "license": "BSD" 14 | } 15 | -------------------------------------------------------------------------------- /examples/querybuilder/person.js: -------------------------------------------------------------------------------- 1 | 2 | // import the necessary modules 3 | var mongoose = require('../../lib'); 4 | var Schema = mongoose.Schema; 5 | 6 | // create an export function to encapsulate the model creation 7 | module.exports = function() { 8 | // define schema 9 | var PersonSchema = new Schema({ 10 | name : String, 11 | age : Number, 12 | birthday : Date 13 | }); 14 | mongoose.model('Person', PersonSchema); 15 | }; 16 | -------------------------------------------------------------------------------- /examples/replicasets/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "replica-set-example", 3 | "private": "true", 4 | "version": "0.0.0", 5 | "description": "deps for replica set example", 6 | "main": "querybuilder.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "dependencies": { "async": "*" }, 11 | "repository": "", 12 | "author": "", 13 | "license": "BSD" 14 | } 15 | -------------------------------------------------------------------------------- /examples/replicasets/person.js: -------------------------------------------------------------------------------- 1 | 2 | // import the necessary modules 3 | var mongoose = require('../../lib'); 4 | var Schema = mongoose.Schema; 5 | 6 | // create an export function to encapsulate the model creation 7 | module.exports = function() { 8 | // define schema 9 | var PersonSchema = new Schema({ 10 | name : String, 11 | age : Number, 12 | birthday : Date 13 | }); 14 | mongoose.model('Person', PersonSchema); 15 | }; 16 | -------------------------------------------------------------------------------- /examples/replicasets/replica-sets.js: -------------------------------------------------------------------------------- 1 | 2 | // import async to make control flow simplier 3 | var async = require('async'); 4 | 5 | // import the rest of the normal stuff 6 | var mongoose = require('../../lib'); 7 | 8 | require('./person.js')(); 9 | 10 | var Person = mongoose.model('Person'); 11 | 12 | // define some dummy data 13 | var data = [ 14 | { name : 'bill', age : 25, birthday : new Date().setFullYear((new 15 | Date().getFullYear() - 25)) }, 16 | { name : 'mary', age : 30, birthday : new Date().setFullYear((new 17 | Date().getFullYear() - 30)) }, 18 | { name : 'bob', age : 21, birthday : new Date().setFullYear((new 19 | Date().getFullYear() - 21)) }, 20 | { name : 'lilly', age : 26, birthday : new Date().setFullYear((new 21 | Date().getFullYear() - 26)) }, 22 | { name : 'alucard', age : 1000, birthday : new Date().setFullYear((new 23 | Date().getFullYear() - 1000)) }, 24 | ]; 25 | 26 | 27 | // to connect to a replica set, pass in the comma delimited uri and optionally 28 | // any connection options such as the rs_name. 29 | var opts = { 30 | replSet : { rs_name : "rs0" } 31 | }; 32 | mongoose.connect('mongodb://localhost:27018/persons,localhost:27019,localhost:27020', opts, function (err) { 33 | if (err) throw err; 34 | 35 | // create all of the dummy people 36 | async.each(data, function (item, cb) { 37 | Person.create(item, cb); 38 | }, function (err) { 39 | 40 | // create and delete some data 41 | var prom = Person.find({age : { $lt : 1000 }}).exec(); 42 | 43 | prom.then(function (people) { 44 | console.log("young people: %s", people); 45 | }).then(cleanup); 46 | }); 47 | }); 48 | 49 | function cleanup() { 50 | Person.remove(function() { 51 | mongoose.disconnect(); 52 | }); 53 | } 54 | -------------------------------------------------------------------------------- /examples/schema/storing-schemas-as-json/index.js: -------------------------------------------------------------------------------- 1 | 2 | // modules 3 | var mongoose = require('../../../lib') 4 | var Schema = mongoose.Schema; 5 | 6 | // parse json 7 | var raw = require('./schema.json'); 8 | 9 | // create a schema 10 | var timeSignatureSchema = Schema(raw); 11 | 12 | // compile the model 13 | var TimeSignature = mongoose.model('TimeSignatures', timeSignatureSchema); 14 | 15 | // create a TimeSignature document 16 | var threeFour = new TimeSignature({ 17 | count: 3 18 | , unit: 4 19 | , description: "3/4" 20 | , additive: false 21 | , created: new Date 22 | , links: ["http://en.wikipedia.org/wiki/Time_signature"] 23 | , user_id: "518d31a0ef32bbfa853a9814" 24 | }); 25 | 26 | // print its description 27 | console.log(threeFour) 28 | -------------------------------------------------------------------------------- /examples/schema/storing-schemas-as-json/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "count": "number", 3 | "unit": "number", 4 | "description": "string", 5 | "links": ["string"], 6 | "created": "date", 7 | "additive": "boolean", 8 | "user_id": "ObjectId" 9 | } 10 | -------------------------------------------------------------------------------- /examples/statics/person.js: -------------------------------------------------------------------------------- 1 | 2 | // import the necessary modules 3 | var mongoose = require('../../lib'); 4 | var Schema = mongoose.Schema; 5 | 6 | // create an export function to encapsulate the model creation 7 | module.exports = function() { 8 | // define schema 9 | var PersonSchema = new Schema({ 10 | name : String, 11 | age : Number, 12 | birthday : Date 13 | }); 14 | 15 | // define a static 16 | PersonSchema.statics.findPersonByName = function (name, cb) { 17 | this.find({ name : new RegExp(name, 'i') }, cb); 18 | }; 19 | 20 | mongoose.model('Person', PersonSchema); 21 | }; 22 | -------------------------------------------------------------------------------- /examples/statics/statics.js: -------------------------------------------------------------------------------- 1 | 2 | var mongoose = require('../../lib'); 3 | 4 | 5 | // import the schema 6 | require('./person.js')(); 7 | 8 | // grab the person model object 9 | var Person = mongoose.model("Person"); 10 | 11 | // connect to a server to do a quick write / read example 12 | 13 | mongoose.connect('mongodb://localhost/persons', function(err) { 14 | if (err) throw err; 15 | 16 | Person.create({ 17 | name : 'bill', 18 | age : 25, 19 | birthday : new Date().setFullYear((new Date().getFullYear() - 25)) 20 | }, function (err, bill) { 21 | if (err) throw err; 22 | console.log("People added to db: %s", bill.toString()); 23 | 24 | // using the static 25 | Person.findPersonByName('bill', function(err, result) { 26 | if (err) throw err; 27 | 28 | console.log(result); 29 | cleanup(); 30 | }); 31 | }); 32 | }); 33 | 34 | function cleanup() { 35 | Person.remove(function() { 36 | mongoose.disconnect(); 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Export lib/mongoose 4 | * 5 | */ 6 | 7 | module.exports = require('./lib/'); 8 | -------------------------------------------------------------------------------- /lib/connectionstate.js: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * Connection states 4 | */ 5 | 6 | var STATES = module.exports = exports = Object.create(null); 7 | 8 | var disconnected = 'disconnected'; 9 | var connected = 'connected'; 10 | var connecting = 'connecting'; 11 | var disconnecting = 'disconnecting'; 12 | var uninitialized = 'uninitialized'; 13 | 14 | STATES[0] = disconnected; 15 | STATES[1] = connected; 16 | STATES[2] = connecting; 17 | STATES[3] = disconnecting; 18 | STATES[99] = uninitialized; 19 | 20 | STATES[disconnected] = 0; 21 | STATES[connected] = 1; 22 | STATES[connecting] = 2; 23 | STATES[disconnecting] = 3; 24 | STATES[uninitialized] = 99; 25 | -------------------------------------------------------------------------------- /lib/drivers/SPEC.md: -------------------------------------------------------------------------------- 1 | 2 | # Driver Spec 3 | 4 | TODO 5 | -------------------------------------------------------------------------------- /lib/drivers/node-mongodb-native/binary.js: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * Module dependencies. 4 | */ 5 | 6 | var Binary = require('mongodb').BSONPure.Binary; 7 | 8 | module.exports = exports = Binary; 9 | -------------------------------------------------------------------------------- /lib/drivers/node-mongodb-native/objectid.js: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) ObjectId 4 | * @constructor NodeMongoDbObjectId 5 | * @see ObjectId 6 | */ 7 | 8 | var ObjectId = require('mongodb').BSONPure.ObjectID; 9 | 10 | /*! 11 | * ignore 12 | */ 13 | 14 | module.exports = exports = ObjectId; 15 | 16 | -------------------------------------------------------------------------------- /lib/error.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * MongooseError constructor 4 | * 5 | * @param {String} msg Error message 6 | * @inherits Error https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error 7 | */ 8 | 9 | function MongooseError (msg) { 10 | Error.call(this); 11 | Error.captureStackTrace(this, arguments.callee); 12 | this.message = msg; 13 | this.name = 'MongooseError'; 14 | }; 15 | 16 | /*! 17 | * Formats error messages 18 | */ 19 | 20 | MongooseError.prototype.formatMessage = function (msg, path, type, val) { 21 | if (!msg) throw new TypeError('message is required'); 22 | 23 | return msg.replace(/{PATH}/, path) 24 | .replace(/{VALUE}/, String(val||'')) 25 | .replace(/{TYPE}/, type || 'declared type'); 26 | } 27 | 28 | /*! 29 | * Inherits from Error. 30 | */ 31 | 32 | MongooseError.prototype.__proto__ = Error.prototype; 33 | 34 | /*! 35 | * Module exports. 36 | */ 37 | 38 | module.exports = exports = MongooseError; 39 | 40 | /** 41 | * The default built-in validator error messages. 42 | * 43 | * @see Error.messages #error_messages_MongooseError-messages 44 | * @api public 45 | */ 46 | 47 | MongooseError.messages = require('./error/messages'); 48 | 49 | // backward compat 50 | MongooseError.Messages = MongooseError.messages; 51 | 52 | /*! 53 | * Expose subclasses 54 | */ 55 | 56 | MongooseError.CastError = require('./error/cast'); 57 | MongooseError.ValidationError = require('./error/validation') 58 | MongooseError.ValidatorError = require('./error/validator') 59 | MongooseError.VersionError =require('./error/version') 60 | MongooseError.OverwriteModelError = require('./error/overwriteModel') 61 | MongooseError.MissingSchemaError = require('./error/missingSchema') 62 | MongooseError.DivergentArrayError = require('./error/divergentArray') 63 | 64 | -------------------------------------------------------------------------------- /lib/error/cast.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Module dependencies. 3 | */ 4 | 5 | var MongooseError = require('../error.js'); 6 | 7 | /** 8 | * Casting Error constructor. 9 | * 10 | * @param {String} type 11 | * @param {String} value 12 | * @inherits MongooseError 13 | * @api private 14 | */ 15 | 16 | function CastError (type, value, path) { 17 | MongooseError.call(this, 'Cast to ' + type + ' failed for value "' + value + '" at path "' + path + '"'); 18 | Error.captureStackTrace(this, arguments.callee); 19 | this.name = 'CastError'; 20 | this.type = type; 21 | this.value = value; 22 | this.path = path; 23 | }; 24 | 25 | /*! 26 | * Inherits from MongooseError. 27 | */ 28 | 29 | CastError.prototype.__proto__ = MongooseError.prototype; 30 | 31 | /*! 32 | * exports 33 | */ 34 | 35 | module.exports = CastError; 36 | -------------------------------------------------------------------------------- /lib/error/divergentArray.js: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * Module dependencies. 4 | */ 5 | 6 | var MongooseError = require('../error.js'); 7 | 8 | /*! 9 | * DivergentArrayError constructor. 10 | * 11 | * @inherits MongooseError 12 | */ 13 | 14 | function DivergentArrayError (paths) { 15 | var msg = 'For your own good, using `document.save()` to update an array ' 16 | + 'which was selected using an $elemMatch projection OR ' 17 | + 'populated using skip, limit, query conditions, or exclusion of ' 18 | + 'the _id field when the operation results in a $pop or $set of ' 19 | + 'the entire array is not supported. The following ' 20 | + 'path(s) would have been modified unsafely:\n' 21 | + ' ' + paths.join('\n ') + '\n' 22 | + 'Use Model.update() to update these arrays instead.' 23 | // TODO write up a docs page (FAQ) and link to it 24 | 25 | MongooseError.call(this, msg); 26 | Error.captureStackTrace(this, arguments.callee); 27 | this.name = 'DivergentArrayError'; 28 | }; 29 | 30 | /*! 31 | * Inherits from MongooseError. 32 | */ 33 | 34 | DivergentArrayError.prototype.__proto__ = MongooseError.prototype; 35 | 36 | /*! 37 | * exports 38 | */ 39 | 40 | module.exports = DivergentArrayError; 41 | -------------------------------------------------------------------------------- /lib/error/messages.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * The default built-in validator error messages. These may be customized. 4 | * 5 | * // customize within each schema or globally like so 6 | * var mongoose = require('mongoose'); 7 | * mongoose.Error.messages.String.enum = "Your custom message for {PATH}."; 8 | * 9 | * As you might have noticed, error messages support basic templating 10 | * 11 | * - `{PATH}` is replaced with the invalid document path 12 | * - `{VALUE}` is replaced with the invalid value 13 | * - `{TYPE}` is replaced with the validator type such as "regexp", "min", or "user defined" 14 | * - `{MIN}` is replaced with the declared min value for the Number.min validator 15 | * - `{MAX}` is replaced with the declared max value for the Number.max validator 16 | * 17 | * Click the "show code" link below to see all defaults. 18 | * 19 | * @property messages 20 | * @receiver MongooseError 21 | * @api public 22 | */ 23 | 24 | var msg = module.exports = exports = {}; 25 | 26 | msg.general = {}; 27 | msg.general.default = "Validator failed for path `{PATH}` with value `{VALUE}`"; 28 | msg.general.required = "Path `{PATH}` is required."; 29 | 30 | msg.Number = {}; 31 | msg.Number.min = "Path `{PATH}` ({VALUE}) is less than minimum allowed value ({MIN})."; 32 | msg.Number.max = "Path `{PATH}` ({VALUE}) is more than maximum allowed value ({MAX})."; 33 | 34 | msg.String = {}; 35 | msg.String.enum = "`{VALUE}` is not a valid enum value for path `{PATH}`."; 36 | msg.String.match = "Path `{PATH}` is invalid ({VALUE})."; 37 | 38 | -------------------------------------------------------------------------------- /lib/error/missingSchema.js: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * Module dependencies. 4 | */ 5 | 6 | var MongooseError = require('../error.js'); 7 | 8 | /*! 9 | * MissingSchema Error constructor. 10 | * 11 | * @inherits MongooseError 12 | */ 13 | 14 | function MissingSchemaError (name) { 15 | var msg = 'Schema hasn\'t been registered for model "' + name + '".\n' 16 | + 'Use mongoose.model(name, schema)'; 17 | MongooseError.call(this, msg); 18 | Error.captureStackTrace(this, arguments.callee); 19 | this.name = 'MissingSchemaError'; 20 | }; 21 | 22 | /*! 23 | * Inherits from MongooseError. 24 | */ 25 | 26 | MissingSchemaError.prototype.__proto__ = MongooseError.prototype; 27 | 28 | /*! 29 | * exports 30 | */ 31 | 32 | module.exports = MissingSchemaError; 33 | -------------------------------------------------------------------------------- /lib/error/overwriteModel.js: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * Module dependencies. 4 | */ 5 | 6 | var MongooseError = require('../error.js'); 7 | 8 | /*! 9 | * OverwriteModel Error constructor. 10 | * 11 | * @inherits MongooseError 12 | */ 13 | 14 | function OverwriteModelError (name) { 15 | MongooseError.call(this, 'Cannot overwrite `' + name + '` model once compiled.'); 16 | Error.captureStackTrace(this, arguments.callee); 17 | this.name = 'OverwriteModelError'; 18 | }; 19 | 20 | /*! 21 | * Inherits from MongooseError. 22 | */ 23 | 24 | OverwriteModelError.prototype.__proto__ = MongooseError.prototype; 25 | 26 | /*! 27 | * exports 28 | */ 29 | 30 | module.exports = OverwriteModelError; 31 | -------------------------------------------------------------------------------- /lib/error/validation.js: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * Module requirements 4 | */ 5 | 6 | var MongooseError = require('../error.js') 7 | 8 | /** 9 | * Document Validation Error 10 | * 11 | * @api private 12 | * @param {Document} instance 13 | * @inherits MongooseError 14 | */ 15 | 16 | function ValidationError (instance) { 17 | MongooseError.call(this, "Validation failed"); 18 | Error.captureStackTrace(this, arguments.callee); 19 | this.name = 'ValidationError'; 20 | this.errors = instance.errors = {}; 21 | }; 22 | 23 | /** 24 | * Console.log helper 25 | */ 26 | 27 | ValidationError.prototype.toString = function () { 28 | var ret = this.name + ': '; 29 | var msgs = []; 30 | 31 | Object.keys(this.errors).forEach(function (key) { 32 | if (this == this.errors[key]) return; 33 | msgs.push(String(this.errors[key])); 34 | }, this) 35 | 36 | return ret + msgs.join(', '); 37 | }; 38 | 39 | /*! 40 | * Inherits from MongooseError. 41 | */ 42 | 43 | ValidationError.prototype.__proto__ = MongooseError.prototype; 44 | 45 | /*! 46 | * Module exports 47 | */ 48 | 49 | module.exports = exports = ValidationError; 50 | -------------------------------------------------------------------------------- /lib/error/validator.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Module dependencies. 3 | */ 4 | 5 | var MongooseError = require('../error.js'); 6 | var errorMessages = MongooseError.messages; 7 | 8 | /** 9 | * Schema validator error 10 | * 11 | * @param {String} path 12 | * @param {String} msg 13 | * @param {String|Number|any} val 14 | * @inherits MongooseError 15 | * @api private 16 | */ 17 | 18 | function ValidatorError (path, msg, type, val) { 19 | if (!msg) msg = errorMessages.general.default; 20 | var message = this.formatMessage(msg, path, type, val); 21 | MongooseError.call(this, message); 22 | Error.captureStackTrace(this, arguments.callee); 23 | this.name = 'ValidatorError'; 24 | this.path = path; 25 | this.type = type; 26 | this.value = val; 27 | }; 28 | 29 | /*! 30 | * toString helper 31 | */ 32 | 33 | ValidatorError.prototype.toString = function () { 34 | return this.message; 35 | } 36 | 37 | /*! 38 | * Inherits from MongooseError 39 | */ 40 | 41 | ValidatorError.prototype.__proto__ = MongooseError.prototype; 42 | 43 | /*! 44 | * exports 45 | */ 46 | 47 | module.exports = ValidatorError; 48 | -------------------------------------------------------------------------------- /lib/error/version.js: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * Module dependencies. 4 | */ 5 | 6 | var MongooseError = require('../error.js'); 7 | 8 | /** 9 | * Version Error constructor. 10 | * 11 | * @inherits MongooseError 12 | * @api private 13 | */ 14 | 15 | function VersionError () { 16 | MongooseError.call(this, 'No matching document found.'); 17 | Error.captureStackTrace(this, arguments.callee); 18 | this.name = 'VersionError'; 19 | }; 20 | 21 | /*! 22 | * Inherits from MongooseError. 23 | */ 24 | 25 | VersionError.prototype.__proto__ = MongooseError.prototype; 26 | 27 | /*! 28 | * exports 29 | */ 30 | 31 | module.exports = VersionError; 32 | -------------------------------------------------------------------------------- /lib/internal.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Dependencies 3 | */ 4 | 5 | var StateMachine = require('./statemachine') 6 | var ActiveRoster = StateMachine.ctor('require', 'modify', 'init', 'default') 7 | 8 | module.exports = exports = InternalCache; 9 | 10 | function InternalCache () { 11 | this.strictMode = undefined; 12 | this.selected = undefined; 13 | this.shardval = undefined; 14 | this.saveError = undefined; 15 | this.validationError = undefined; 16 | this.adhocPaths = undefined; 17 | this.removing = undefined; 18 | this.inserting = undefined; 19 | this.version = undefined; 20 | this.getters = {}; 21 | this._id = undefined; 22 | this.populate = undefined; // what we want to populate in this doc 23 | this.populated = undefined;// the _ids that have been populated 24 | this.wasPopulated = false; // if this doc was the result of a population 25 | this.scope = undefined; 26 | this.activePaths = new ActiveRoster; 27 | 28 | // embedded docs 29 | this.ownerDocument = undefined; 30 | this.fullPath = undefined; 31 | } 32 | -------------------------------------------------------------------------------- /lib/schema/index.js: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * Module exports. 4 | */ 5 | 6 | exports.String = require('./string'); 7 | 8 | exports.Number = require('./number'); 9 | 10 | exports.Boolean = require('./boolean'); 11 | 12 | exports.DocumentArray = require('./documentarray'); 13 | 14 | exports.Array = require('./array'); 15 | 16 | exports.Buffer = require('./buffer'); 17 | 18 | exports.Date = require('./date'); 19 | 20 | exports.ObjectId = require('./objectid'); 21 | 22 | exports.Mixed = require('./mixed'); 23 | 24 | // alias 25 | 26 | exports.Oid = exports.ObjectId; 27 | exports.Object = exports.Mixed; 28 | exports.Bool = exports.Boolean; 29 | -------------------------------------------------------------------------------- /lib/schema/mixed.js: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * Module dependencies. 4 | */ 5 | 6 | var SchemaType = require('../schematype'); 7 | var utils = require('../utils'); 8 | 9 | /** 10 | * Mixed SchemaType constructor. 11 | * 12 | * @param {String} path 13 | * @param {Object} options 14 | * @inherits SchemaType 15 | * @api private 16 | */ 17 | 18 | function Mixed (path, options) { 19 | if (options && options.default) { 20 | var def = options.default; 21 | if (Array.isArray(def) && 0 === def.length) { 22 | // make sure empty array defaults are handled 23 | options.default = Array; 24 | } else if (!options.shared && 25 | utils.isObject(def) && 26 | 0 === Object.keys(def).length) { 27 | // prevent odd "shared" objects between documents 28 | options.default = function () { 29 | return {} 30 | } 31 | } 32 | } 33 | 34 | SchemaType.call(this, path, options); 35 | }; 36 | 37 | /*! 38 | * Inherits from SchemaType. 39 | */ 40 | 41 | Mixed.prototype.__proto__ = SchemaType.prototype; 42 | 43 | /** 44 | * Required validator 45 | * 46 | * @api private 47 | */ 48 | 49 | Mixed.prototype.checkRequired = function (val) { 50 | return (val !== undefined) && (val !== null); 51 | }; 52 | 53 | /** 54 | * Casts `val` for Mixed. 55 | * 56 | * _this is a no-op_ 57 | * 58 | * @param {Object} value to cast 59 | * @api private 60 | */ 61 | 62 | Mixed.prototype.cast = function (val) { 63 | return val; 64 | }; 65 | 66 | /** 67 | * Casts contents for queries. 68 | * 69 | * @param {String} $cond 70 | * @param {any} [val] 71 | * @api private 72 | */ 73 | 74 | Mixed.prototype.castForQuery = function ($cond, val) { 75 | if (arguments.length === 2) return val; 76 | return $cond; 77 | }; 78 | 79 | /*! 80 | * Module exports. 81 | */ 82 | 83 | module.exports = Mixed; 84 | -------------------------------------------------------------------------------- /lib/schemadefault.js: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * Module dependencies. 4 | */ 5 | 6 | var Schema = require('./schema') 7 | 8 | /** 9 | * Default model for querying the system.profiles collection. 10 | * 11 | * @property system.profile 12 | * @receiver exports 13 | * @api private 14 | */ 15 | 16 | exports['system.profile'] = new Schema({ 17 | ts: Date 18 | , info: String // deprecated 19 | , millis: Number 20 | , op: String 21 | , ns: String 22 | , query: Schema.Types.Mixed 23 | , updateobj: Schema.Types.Mixed 24 | , ntoreturn: Number 25 | , nreturned: Number 26 | , nscanned: Number 27 | , responseLength: Number 28 | , client: String 29 | , user: String 30 | , idhack: Boolean 31 | , scanAndOrder: Boolean 32 | , keyUpdates: Number 33 | , cursorid: Number 34 | }, { noVirtualId: true, noId: true }); 35 | -------------------------------------------------------------------------------- /lib/types/index.js: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * Module exports. 4 | */ 5 | 6 | exports.Array = require('./array'); 7 | exports.Buffer = require('./buffer'); 8 | 9 | exports.Document = // @deprecate 10 | exports.Embedded = require('./embedded'); 11 | 12 | exports.DocumentArray = require('./documentarray'); 13 | exports.ObjectId = require('./objectid'); 14 | -------------------------------------------------------------------------------- /lib/types/objectid.js: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * Access driver. 4 | */ 5 | 6 | var driver = global.MONGOOSE_DRIVER_PATH || '../drivers/node-mongodb-native'; 7 | 8 | /** 9 | * ObjectId type constructor 10 | * 11 | * ####Example 12 | * 13 | * var id = new mongoose.Types.ObjectId; 14 | * 15 | * @constructor ObjectId 16 | */ 17 | 18 | var ObjectId = require(driver + '/objectid'); 19 | module.exports = ObjectId; 20 | 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mongoose" 3 | , "description": "Mongoose MongoDB ODM" 4 | , "version": "3.8.13-pre" 5 | , "author": "Guillermo Rauch " 6 | , "keywords": ["mongodb", "document", "model", "schema", "database", "odm", "data", "datastore", "query", "nosql", "orm", "db"] 7 | , "dependencies": { 8 | "mongodb": "1.4.5" 9 | , "hooks": "0.2.1" 10 | , "ms": "0.1.0" 11 | , "sliced": "0.0.5" 12 | , "muri": "0.3.1" 13 | , "mpromise": "0.4.3" 14 | , "mpath": "0.1.1" 15 | , "regexp-clone": "0.0.1" 16 | , "mquery" : "0.8.0" 17 | } 18 | , "devDependencies": { 19 | "mocha": "1.12.0" 20 | , "node-static": "0.5.9" 21 | , "dox": "0.3.1" 22 | , "jade": "0.26.3" 23 | , "highlight.js": "7.0.1" 24 | , "markdown": "0.3.1" 25 | , "promises-aplus-tests": ">= 1.0.2" 26 | , "tbd": "0.6.4" 27 | , "benchmark" : "1.0.0" 28 | , "open": "0.0.3" 29 | , "async": "0.2.5" 30 | , "underscore": "1.5.2" 31 | } 32 | , "directories": { "lib": "./lib/mongoose" } 33 | , "scripts": { "test": "make test" } 34 | , "main": "./index.js" 35 | , "engines": { "node": ">=0.6.19" } 36 | , "bugs": { 37 | "url":"https://github.com/learnboost/mongoose/issues/new" 38 | , "email": "mongoose-orm@googlegroups.com" 39 | } 40 | , "repository": { 41 | "type": "git" 42 | , "url": "git://github.com/LearnBoost/mongoose.git" 43 | } 44 | , "homepage": "http://mongoosejs.com" 45 | } 46 | -------------------------------------------------------------------------------- /release-items.md: -------------------------------------------------------------------------------- 1 | ## mongoose release procedure 2 | 3 | 1. tests must pass 4 | 2. update package.json version 5 | 3. update History.md using `git changelog` or similar. list the related ticket(s) # as well as a link to the github user who fixed it if applicable. 6 | 4. git commit -m 'release x.x.x' 7 | 5. git tag x.x.x 8 | 6. git push origin BRANCH --tags && npm publish 9 | 7. update mongoosejs.com (see "updating the website" below) 10 | 8. announce to google groups - include the relevant change log and links to issues 11 | 9. tweet google group announcement from [@mongoosejs](https://twitter.com/mongoosejs) 12 | 10. announce on #mongoosejs irc room 13 | 11. change package.json version to next patch version suffixed with '-pre' and commit "now working on x.x.x" 14 | 12. if this is a stable release, update the unstable History.md with the changelog 15 | 16 | ## updating the website 17 | 18 | For 3.8.x: 19 | 20 | 0. Change to the 3.8.x branch 21 | 1. execute `make docs` (when this process completes you'll be on the gh-pages branch) 22 | 2. `git add docs/*.html index.html` 23 | 3. `git commit -m 'website; regen '` 24 | 4. `git push origin gh-pages` 25 | 26 | For unstable: 27 | 28 | 0. Change to the master branch 29 | 1. execute `make docs_unstable` (when this process completes you'll be on the gh-pages branch) 30 | 2. `git add docs/unstable/docs/*.html docs/unstable/index.html` 31 | 3. `git commit -m 'website; regen '` 32 | 4. `git push origin gh-pages` 33 | -------------------------------------------------------------------------------- /static.js: -------------------------------------------------------------------------------- 1 | 2 | var static = require('node-static'); 3 | var server = new static.Server('.', { cache: 0 }); 4 | var open = require('open') 5 | 6 | require('http').createServer(function (req, res) { 7 | if ('/favicon.ico' == req.url) { 8 | req.destroy(); 9 | res.statusCode = 204 10 | return res.end(); 11 | } 12 | 13 | req.on('end', function () { 14 | server.serve(req, res, function (err) { 15 | if (err) { 16 | console.error(err, req.url); 17 | res.writeHead(err.status, err.headers); 18 | res.end(); 19 | } 20 | }); 21 | }); 22 | req.resume(); 23 | }).listen(8088); 24 | 25 | console.error('now listening on http://localhost:8088'); 26 | open('http://localhost:8088'); 27 | -------------------------------------------------------------------------------- /test/_goosetest.js: -------------------------------------------------------------------------------- 1 | 2 | var mongoose = require('../../'); 3 | var Schema = mongoose.Schema; 4 | var assert = require('assert') 5 | 6 | console.log('\n==========='); 7 | console.log(' mongoose version: %s', mongoose.version); 8 | console.log('========\n\n'); 9 | 10 | var dbname = 'goosetest-{NAME}'; 11 | mongoose.connect('localhost', dbname); 12 | mongoose.connection.on('error', function () { 13 | console.error('connection error', arguments); 14 | }); 15 | 16 | 17 | var schema = new Schema({ 18 | name: String 19 | }); 20 | 21 | var A = mongoose.model('A', schema); 22 | 23 | 24 | mongoose.connection.on('open', function () { 25 | var a = new A({ name: '{NAME}' }); 26 | 27 | a.save(function (err) { 28 | if (err) return done(err); 29 | 30 | A.findById(a, function (err, doc) { 31 | console.log(arguments); 32 | done(err); 33 | }) 34 | }) 35 | }); 36 | 37 | function done (err) { 38 | if (err) console.error(err.stack); 39 | mongoose.connection.db.dropDatabase(function () { 40 | mongoose.connection.close(); 41 | }); 42 | } 43 | -------------------------------------------------------------------------------- /test/connection.auth.test.js: -------------------------------------------------------------------------------- 1 | 2 | var start = require('./common'); 3 | var mongoose = start.mongoose; 4 | var assert = require('assert'); 5 | 6 | describe('connection:', function(){ 7 | describe('supports authSource', function(){ 8 | 9 | it('in querystring', function(done){ 10 | var conn = mongoose.createConnection(); 11 | conn._open = function () { 12 | assert.ok(conn.options); 13 | assert.ok(conn.options.auth); 14 | assert.equal('users', conn.options.auth.authSource); 15 | done(); 16 | } 17 | conn.open(start.uri + '?authSource=users'); 18 | }) 19 | 20 | it('passed as an option', function(done){ 21 | var conn = mongoose.createConnection(); 22 | conn._open = function () { 23 | assert.ok(conn.options); 24 | assert.ok(conn.options.auth); 25 | assert.equal('users', conn.options.auth.authSource); 26 | done(); 27 | } 28 | conn.open(start.uri, { auth: { authSource: 'users' }}); 29 | }) 30 | }) 31 | }) 32 | -------------------------------------------------------------------------------- /test/connection.reconnect.test.js: -------------------------------------------------------------------------------- 1 | 2 | var start = require('./common'); 3 | var mongoose = start.mongoose; 4 | var assert = require('assert'); 5 | 6 | describe('connection: manual reconnect with authReconnect: false', function(){ 7 | it('should continue processing queries/writes', function(done){ 8 | // connect to mongod 9 | // perform writes/queries 10 | // take mongod down 11 | // bring mongod up 12 | // writes/queries should work 13 | // - should not get 'no open connections' error 14 | 15 | var db = mongoose.createConnection(); 16 | 17 | db.open(start.uri, { server: { auto_reconnect: false }}); 18 | 19 | var M = db.model('autoReconnect', { name: String }); 20 | 21 | var open = false; 22 | var times = 0; 23 | 24 | db.on('open', function () { 25 | ++times; 26 | open = true; 27 | hit(); 28 | }) 29 | 30 | db.on('disconnected', function () { 31 | open = false; 32 | setTimeout(function () { 33 | db.open(start.uri, { server: { auto_reconnect: false }}); 34 | }, 30); 35 | }) 36 | 37 | function hit () { 38 | if (!open) return; 39 | M.create({ name: times }, function (err, doc) { 40 | if (err) return complete(err); 41 | M.findOne({ _id: doc._id }, function (err, found) { 42 | if (err) return complete(err); 43 | if (times > 1) { 44 | return complete(); 45 | } 46 | shutdownMongo(); 47 | }) 48 | }) 49 | } 50 | 51 | function shutdownMongo () { 52 | db.db.close(); 53 | } 54 | 55 | function complete (err) { 56 | if (complete.ran) return ; 57 | complete.ran = 1; 58 | done(err); 59 | } 60 | }) 61 | }) 62 | -------------------------------------------------------------------------------- /test/crash.test.js: -------------------------------------------------------------------------------- 1 | 2 | // GH-407 3 | 4 | var start = require('./common') 5 | , assert = require('assert') 6 | , mongoose = start.mongoose 7 | 8 | describe('crash: (gh-407)', function(){ 9 | it('test mongodb crash with invalid objectid string', function(done){ 10 | var db = mongoose.createConnection("mongodb://localhost/test-crash"); 11 | 12 | var IndexedGuy = new mongoose.Schema({ 13 | name: { type: String } 14 | }); 15 | 16 | var Guy = db.model('Guy', IndexedGuy); 17 | Guy.find({ 18 | _id: { 19 | $in: [ 20 | '4e0de2a6ee47bff98000e145', 21 | '4e137bd81a6a8e00000007ac', 22 | '', 23 | '4e0e2ca0795666368603d974'] 24 | } 25 | }, function (err) { 26 | db.close(); 27 | 28 | try { 29 | assert.equal('Cast to ObjectId failed for value "" at path "_id"', err.message); 30 | } catch (er) { 31 | console.error(err); 32 | throw er; 33 | } 34 | done(); 35 | }); 36 | 37 | }) 38 | }) 39 | 40 | -------------------------------------------------------------------------------- /test/createtest: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # copy our _goosetest.js to another filename passed on the cmd line 3 | # and replace all occurances of {NAME} with the filename too. 4 | test $# -ne 1 && echo "usage: createtest scriptname" && exit 0; 5 | 6 | # EDITOR must be set 7 | test -e $EDITOR && echo "Please set your EDITOR environment variable" && exit 0; 8 | 9 | # does the file they are about to create exist? 10 | if test -e triage/$1.js; then 11 | # do not overwrite. open for editing. 12 | $EDITOR triage/$1.js 13 | else 14 | # create 15 | cat _goosetest.js | sed "s/{NAME}/$1/g" >> triage/$1.js 16 | $EDITOR triage/$1.js 17 | fi 18 | -------------------------------------------------------------------------------- /test/dropdb.js: -------------------------------------------------------------------------------- 1 | var start = require('./common') 2 | var db = start(); 3 | db.once('open', function () { 4 | 5 | // drop the default test database 6 | db.db.dropDatabase(function () { 7 | var db2 = db.useDb('mongoose-test-2'); 8 | db2.db.dropDatabase(function() { 9 | // drop mongos test db if exists 10 | var mongos = process.env.MONGOOSE_MULTI_MONGOS_TEST_URI; 11 | if (!mongos) return process.exit(); 12 | 13 | 14 | var db = start({ uri: mongos, mongos: true }); 15 | db.once('open', function () { 16 | db.db.dropDatabase(process.exit); 17 | }); 18 | }); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /test/errors.mongoose.test.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Module dependencies. 4 | */ 5 | 6 | var assert = require('assert') 7 | , start = require('./common') 8 | , mongoose = start.mongoose 9 | 10 | describe('MongooseError', function(){ 11 | describe('#formatMessage', function(){ 12 | it('replaces {PATH}, {TYPE}, and {VALUE} correctly', function(done){ 13 | var err = new mongoose.Error; 14 | var expect = 'value; path; type'; 15 | var actual = err.formatMessage('{VALUE}; {PATH}; {TYPE}', 'path', 'type', 'value'); 16 | assert.equal(expect, actual); 17 | done(); 18 | }) 19 | it('throws when no message is passed', function(done){ 20 | var err = new mongoose.Error; 21 | assert.throws(function () { 22 | err.formatMessage(undefined, 'a', 'b', 'c'); 23 | }, /message is required/) 24 | done(); 25 | }) 26 | }) 27 | }) 28 | -------------------------------------------------------------------------------- /test/schema.boolean.test.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Module dependencies. 4 | */ 5 | 6 | var start = require('./common') 7 | , mongoose = start.mongoose 8 | , assert = require('assert') 9 | , Schema = mongoose.Schema 10 | 11 | describe('schematype', function(){ 12 | describe('boolean', function(){ 13 | it('null default is permitted (gh-523)', function(done){ 14 | var db = start() 15 | , s1 = new Schema({ b: { type: Boolean, default: null }}) 16 | , M1 = db.model('NullDateDefaultIsAllowed1', s1) 17 | , s2 = new Schema({ b: { type: Boolean, default: false }}) 18 | , M2 = db.model('NullDateDefaultIsAllowed2', s2) 19 | , s3 = new Schema({ b: { type: Boolean, default: true }}) 20 | , M3 = db.model('NullDateDefaultIsAllowed3', s3) 21 | 22 | db.close(); 23 | 24 | var m1 = new M1; 25 | assert.strictEqual(null, m1.b); 26 | var m2 = new M2; 27 | assert.strictEqual(false, m2.b); 28 | var m3 = new M3; 29 | assert.strictEqual(true, m3.b); 30 | done(); 31 | }) 32 | }) 33 | }) 34 | -------------------------------------------------------------------------------- /test/schema.documentarray.test.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Module dependencies. 4 | */ 5 | 6 | var start = require('./common') 7 | , mongoose = start.mongoose 8 | , assert = require('assert') 9 | , random = require('../lib/utils').random 10 | , Schema = mongoose.Schema 11 | 12 | /** 13 | * Test. 14 | */ 15 | 16 | describe('schema.documentarray', function(){ 17 | it('defaults should be preserved', function(done){ 18 | var child = new Schema({ title: String }) 19 | 20 | var schema1 = new Schema({ x: { type: [child], default: [{ title: 'Prometheus'}] }}); 21 | var schema2 = new Schema({ x: { type: [child], default: { title: 'Prometheus'} }}); 22 | var schema3 = new Schema({ x: { type: [child], default: function(){return [{ title: 'Prometheus'}]} }}); 23 | 24 | var M = mongoose.model('DefaultDocArrays1', schema1); 25 | var N = mongoose.model('DefaultDocArrays2', schema2); 26 | var O = mongoose.model('DefaultDocArrays3', schema3); 27 | 28 | [M,N,O].forEach(function (M) { 29 | var m = new M; 30 | assert.ok(Array.isArray(m.x)); 31 | assert.equal(1, m.x.length); 32 | assert.equal('Prometheus', m.x[0].title); 33 | }); 34 | done(); 35 | }) 36 | }) 37 | -------------------------------------------------------------------------------- /test/schema.mixed.test.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Module dependencies. 4 | */ 5 | 6 | var start = require('./common') 7 | , mongoose = new start.mongoose.Mongoose 8 | , assert = require('assert') 9 | , Schema = mongoose.Schema 10 | 11 | describe('schematype mixed', function(){ 12 | describe('empty object defaults (gh-1380)', function(){ 13 | it('are interpreted as fns that return new empty objects', function(done){ 14 | var s = Schema({ mix: { type: Schema.Types.Mixed, default: {} }}) 15 | var M = mongoose.model('M1', s); 16 | var m1 = new M; 17 | var m2 = new M; 18 | m1.mix.val = 3; 19 | assert.equal(3, m1.mix.val); 20 | assert.equal(undefined, m2.mix.val); 21 | done(); 22 | }) 23 | it('can be forced to share the object between documents', function(done){ 24 | // silly but necessary for backwards compatibility 25 | var s = Schema({ mix: { type: Schema.Types.Mixed, default: {}, shared: true }}) 26 | var M = mongoose.model('M2', s); 27 | var m1 = new M; 28 | var m2 = new M; 29 | m1.mix.val = 3; 30 | assert.equal(3, m1.mix.val); 31 | assert.equal(3, m2.mix.val); 32 | done(); 33 | }) 34 | }) 35 | }) 36 | -------------------------------------------------------------------------------- /test/schema.type.test.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Module dependencies. 4 | */ 5 | 6 | var mongoose = require('./common').mongoose 7 | , assert = require('assert') 8 | , Schema = mongoose.Schema 9 | 10 | describe('schematype', function(){ 11 | it('honors the selected option', function(done){ 12 | var s = new Schema({ thought: { type: String, select: false }}); 13 | assert.equal(false, s.path('thought').selected); 14 | 15 | var a = new Schema({ thought: { type: String, select: true }}); 16 | assert.equal(true, a.path('thought').selected); 17 | done(); 18 | }) 19 | 20 | it('properly handles specifying index in combination with unique or sparse', function(done){ 21 | var s = new Schema({ name: { type: String, index: true, unique: true }}); 22 | assert.deepEqual(s.path('name')._index, { unique: true }); 23 | var s = new Schema({ name: { type: String, unique: true, index: true }}); 24 | assert.deepEqual(s.path('name')._index, { unique: true }); 25 | var s = new Schema({ name: { type: String, index: true, sparse: true }}); 26 | assert.deepEqual(s.path('name')._index, { sparse: true }); 27 | var s = new Schema({ name: { type: String, sparse: true, index: true }}); 28 | assert.deepEqual(s.path('name')._index, { sparse: true }); 29 | done(); 30 | }) 31 | }) 32 | -------------------------------------------------------------------------------- /test/triage/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KingNigel/mongoose/54d0042d5b04ed62c7b64c49b87886c59b214862/test/triage/.gitignore --------------------------------------------------------------------------------