• Stars
    star
    100
  • Rank 340,703 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 10 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

📦 A hapi plugin for `mongo-models`

hapi-mongo-models

A hapi plugin for mongo-models.

Build Status Dependency Status devDependency Status peerDependency Status

Install

$ npm install hapi-mongo-models

Server plugin

During plugin registration we connect to MongoDB using the supplied options.

During Hapi's onPreStart server extension point and based on your autoIndex option, we create any indexes defined in the models supplied.

Register

const HapiMongoModels = require('hapi-mongo-models');

const plugin = {
    plugin: HapiMongoModels,
    options: {
        mongodb: {
            connection: {
                uri: 'mongodb://localhost:27017/',
                db: 'hapi-mongo-models-test'
            },
            options: {}
        },
        models: [
            './path/to/customer',
            './path/to/order'
        ],
        autoIndex: false
    }
};

await server.register(plugin);

Plugin options

The options passed to the plugin is an object where:

  • mongodb - is an object where:
    • connection - is an object where:
      • uri - a string representing the connection uri for MongoDB.
      • db - the name of the database.
    • options - an optional object passed to MongoDB's native connect function.
  • autoIndex - a boolean specifying if the plugin should call createIndexes for each model that has a static indexes property. Defaults to true. Typically set to false in production environments.
  • models - an array strings representing the paths to the models (relative to the current working directory or absolute) of where to find the model on disk.

Have a question?

Any issues or questions (no matter how basic), open an issue. Please take the initiative to read relevant documentation and be pro-active with debugging.

Want to contribute?

Contributions are welcome. If you're changing something non-trivial, you may want to submit an issue before creating a large pull request.

Note: This plugin is designed for basic use-cases. If you find yourself needing more, consider using the source as inspiration and create a custom plugin for your app.

License

MIT

Don't forget

What you create with hapi-mongo-models is more important than hapi-mongo-models.

More Repositories

1

drywall

🚧 Project moved, see Aqua and Frame
JavaScript
2,180
star
2

aqua

💡 A website and user system starter
JavaScript
1,377
star
3

frame

💡 A user system API starter
JavaScript
740
star
4

hapi-react-views

📦 A hapi view engine for React components
JavaScript
231
star
5

generator-hapi-style

📦 Yeoman generator for scaffolding hapi apps and plugins
JavaScript
95
star
6

gimp-hidpi

A theme for HiDPI displays
78
star
7

mongo-models

📦 Map JavaScript classes to MongoDB collections
JavaScript
67
star
8

reserved-subdomains

📦 A list of names that should be reserved in multitenant apps.
JavaScript
46
star
9

warc

⚙️ A Rust library for reading and writing WARC files
Rust
44
star
10

hapi-node-postgres

📦 Wrap hapi requests with a pg connection
JavaScript
31
star
11

flux-store

📦 A simple store for Flux
JavaScript
21
star
12

flux-constant

📦 Unique constants for Flux apps
JavaScript
18
star
13

nodeschool

my nodeschool.io answers
JavaScript
13
star
14

mini-isomorphic-react

The world's smallest isomorphic React demo
JavaScript
6
star
15

projecteuler-js

My projecteuler.net solutions in JavaScript
JavaScript
4
star
16

vim-rizzle

A dark vim color scheme.
Vim Script
3
star
17

conways-yolo

Conway's Game of Life using HTML5 canvas
JavaScript
2
star
18

flatly

🚧 INACTIVE - A small, static website generator written in Node.js
JavaScript
2
star
19

flux-dispatcher

📦 A Flux dispatcher ready for action
JavaScript
2
star
20

hapi-remote-address

Provides `request.remoteAddress` with support for `X-Forwarded-For` headers.
JavaScript
2
star
21

sweep-or-die

A rendition of Minesweeper in JavaScript, HTML and CSS
JavaScript
2
star
22

connected-devices-sf

The SF chapter hub
HTML
1
star
23

j5-experiment

JavaScript
1
star
24

gh-identicon-parser

Parses a GitHub identicon into an array
JavaScript
1
star
25

host-header-trick

🚨 Demo code. Use at your own risk.
JavaScript
1
star
26

hello-watson

🚧 fiddle with IBM watson
JavaScript
1
star
27

dotxmonad

myxmonad settings
Haskell
1
star
28

weblegs-legacy-libs

🚧 INACTIVE - Weblegs libs for VB, C#, Java, Perl, PHP and JS
ASP
1
star
29

weblegs

🚧 INACTIVE - A very naive PHP framework
PHP
1
star
30

dotfiles

My dotfiles
Vim Script
1
star
31

projecteuler-rs

My projecteuler.net solutions in Rust
Rust
1
star
32

visionary

Views loader plugin for hapi.js
JavaScript
1
star
33

fxos-docker

A development environment for FxOS
Shell
1
star
34

joistick

📦 Default values for Joi schemas
JavaScript
1
star
35

bingo

JavaScript
1
star
36

ugly-assets

Watch, lint and build your .js and .less assets
JavaScript
1
star
37

drywall-screen-shots

Using CasperJS to generate Drywall demo screen shots
JavaScript
1
star
38

aqua-screenshots

Using CasperJS to generate Aqua demo screen shots
JavaScript
1
star
39

lab-es6

Demonstrating Lab & ES6
HTML
1
star