-
Notifications
You must be signed in to change notification settings - Fork 131
Can you use mongoose and mongodb services together? #251
Comments
I reverted my code. Confirmed the test ran with only calls to the 2 mongoose collections. I then ran I got the same error as above. |
When you create a mongoose service, src/mongodb.js is const mongoose = require('mongoose');
module.exports = function () {
const app = this;
mongoose.connect(app.get('mongodb'));
mongoose.Promise = global.Promise;
app.set('mongooseClient', mongoose);
}; When you add a mongodb service, its overridden with const MongoClient = require('mongodb').MongoClient;
module.exports = function () {
const app = this;
const config = app.get('mongodb');
const promise = MongoClient.connect(config);
app.set('mongoClient', promise);
}; So the generator does not support mongoose and mongo db clients simultaniously. |
Just to confirm, the mongoose test run OK with the following. I assume the mongo will also. 'use strict';
const MongoClient = require('mongodb').MongoClient;
const mongoose = require('mongoose');
module.exports = function () {
const app = this;
const config = app.get('mongodb');
const promise = MongoClient.connect(config);
app.set('mongoClient', promise);
mongoose.connect(config);
mongoose.Promise = global.Promise;
app.set('mongooseClient', mongoose);
}; |
This should be fixed already via #229. Did you have the latest version of |
The mongo test threw because the mongoDB setup does not wait for This is really a separate issue so I created #253 |
Yup, the current feathers-cli handles this. Nice! Thanks. |
My test app worked with 2 nedb plus 2 mongoose services. That original test threw after I added a mongodb service with the generator.
The problem seems to be that
app.get('mongooseClient')
now returns undefined. That value was being set outside my code when the test app worked.I commented out the
require
andapp.configure
for the new mongodb service in src/services/index.js. That should have brought the app back to the way it was. However I was surprised to still get the same error.Can an app use a mongoose and mongodb service together?
Edit: I now see
app.get('mongooseClient')
is set in src/mongodb.jsThe text was updated successfully, but these errors were encountered: