adonis-mongorito
AdonisJS Addon Provider for Mongorito (mongodb package for nodejs)
Installation
$ npm install adonis-mongorito --save
The command above will install the package mongorito too.
You need to create a config/mongo.js
file with the contents:
'use strict' const Env = moduleexports = host: Env port: Env user: Env pass: Env db: Env
You are using a connection local without user and pass, leave it blank like on the example.
Add the entry adonis-mongorito/providers/MongoritoProvider.js
to the providers array on bootstrap/app.js
like this:
const providers = 'adonis-framework/providers/ConfigProvider' 'adonis-framework/providers/EnvProvider' //..OTHER DEFAULT PROVIDERS...// 'adonis-middleware/providers/AppMiddlewareProvider' 'adonis-auth/providers/AuthManagerProvider' 'adonis-mongorito/providers/MongoritoProvider' //add this line after install the package
Add the entry MongoritoModel: 'Adonis/Addons/MongoritoModel'
on the aliases
object on bootstrap/app.js
file like this:
const aliases = Command: 'Adonis/Src/Command' Config: 'Adonis/Src/Config' //..OTHER DEFAULT PROVIDERS...// View: 'Adonis/Src/View' MongoritoModel: 'Adonis/Addons/MongoritoModel' //this line
Usage
Now you can create Mongo MODELS like Lucid Models
app/Model/Post.js
'use strict' const MongoritoModel = moduleexports = Post
And use like this:
app/Http/routes.js
'use strict' const Route = const Post = Route Route
As you can see, it's very easy to use.
How to use Mongorito stuff?
- Mongorito Official site/docs: https://mongorito.com
- Mongorito Repository: https://github.com/vdemedes/mongorito
Found any Bugs?
Please before open a Issue on this repository, check if it's not a bug on Mongorito package here: https://github.com/vdemedes/mongorito/issues
License
Adonis-Mongorito is released under the MIT License.