hapi-mongojs
A tiny plugin to share a common MongoDB connection pool across the whole Hapi server using mongojs and ensure collection indexes.
Setup
npm install --save hapi-mongojs
example
Run the # remember to start MongoDB npm run example:installnpm run example:start # verify if server is running http://localhost:8888/status# run the example http://localhost:8888/example
Example
const Hapi = ;const Boom = ;// IMPORT NPM DEPENDENCYconst mongojs = ; // ADD PLUGINS CONFIGconst plugins = register: mongojs options: url: 'mongodb://localhost:27017/myDatabase' // ENSURE COLLECTION INDEXES (OPTIONAL) collections: name: 'myCollection1' indexes: keys: 'aField': 1 options: 'unique': true 'name': 'afield_idx' ; const server = ; server; server; server;