Skip to content

Commit

Permalink
Merge pull request 3.0.1
Browse files Browse the repository at this point in the history
3.0.1: fixed Mongoose singleton being defered
  • Loading branch information
juampi92 authored Apr 24, 2018
2 parents 31b960a + c1603cb commit 1c60524
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 12 deletions.
7 changes: 0 additions & 7 deletions instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ const providers = [
]
```

And create an Alias for Mongoose

```js
const aliases = {
Mongoose: 'Adonis/Addons/Mongoose'
}
```
## Config mongodb connection

Finally add the database config inside `config/database.js` file.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adonis-mongoose-model",
"version": "3.0.0",
"version": "3.0.1",
"description": "Mongoose models for Adonis framework",
"main": "index.js",
"repository": "[email protected]:juampi92/adonis-mongoose-model.git",
Expand Down
4 changes: 2 additions & 2 deletions providers/MongooseProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MongooseProvider extends ServiceProvider {
'serializer')
}

async _registerMongoose () {
_registerMongoose () {
this.app.singleton('Adonis/Addons/Mongoose', function (app) {
const Config = app.use('Adonis/Src/Config')
let connectionString = Config.get('database.mongodb.connectionString', null)
Expand Down Expand Up @@ -85,7 +85,7 @@ class MongooseProvider extends ServiceProvider {
this._registerSerializer()
this._registerModel()
this._registerCommands()
await this._registerMongoose()
this._registerMongoose()
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

require('@adonisjs/fold')

const mongoose = use('mongoose')
const mongoose = use('Adonis/Addons/Mongoose')
const { Schema } = mongoose

const utils = require('../utils')
Expand Down
3 changes: 2 additions & 1 deletion test/ioc.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const ServiceProvider = require('../providers/MongooseProvider')

test.group('IoC', function () {
// Setup
ioc.fake('Mongoose', () => require('mongoose'))
ioc.fake('Adonis/Addons/Mongoose', () => require('mongoose'))
ioc.fake('Mongoose', () => ioc.use('Adonis/Addons/Mongoose'))

const BaseModel = require('../src/Model/Base')

Expand Down

0 comments on commit 1c60524

Please sign in to comment.