Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gtfs.getStops() throws Mongoose DeprecationWarning #82

Closed
Kenny806 opened this issue Nov 3, 2017 · 3 comments
Closed

gtfs.getStops() throws Mongoose DeprecationWarning #82

Kenny806 opened this issue Nov 3, 2017 · 3 comments

Comments

@Kenny806
Copy link

Kenny806 commented Nov 3, 2017

Hi, I tried creating a simple example that would download my local agency's timetables and just print the available stops to console. I set mongoose.promise in my code, but still get a warning when I call gtfs.getStops(). My code is:

const config = require('./config.json');
const gtfs = require('gtfs');
var mongo = require('mongodb');
var mongoose = require('mongoose');

mongoose.Promise = global.Promise;

mongoose.connect(config.mongoUrl, {useMongoClient: true}).then(function() {
    console.log('connected')
    gtfs.getStops({
        agency_key: 'dpp'
    })
    .then(stops => {
        console.log(stops);
    });
}).catch(err => console.log(err));

config.json:

{
  "mongoUrl": "mongodb://localhost:27017/gtfs",
  "agencies": [
    {
      "agency_key": "dpp",
      "url": "http://opendata.iprpraha.cz/DPP/JR/jrdata.zip"
    }
  ]
}

I am using mongoose 4.11.8 and I ran gtfs.import and it reported no errors, and I did not find any problems in the db either. I found this issue on mongoose github and it seems there is a workaround, but it would require inserting
mongoose.promise = global.Promise
into almost every file that accesses the db, including gtfs files. Have you encountered this issue before or do you have any more feasible workaround?

Thanks

@brendannee
Copy link
Member

brendannee commented Nov 3, 2017 via email

@Kenny806
Copy link
Author

Kenny806 commented Nov 3, 2017

Thanks, that helped!

It was specified as a dependency in my package.json. I removed it, reinstalled node_modules and now it works fine.

The only slight issue is, that when I want to access mongoose in my project, I have to require the one installed as a dependency of node-gtfs. Like this:
const mongoose = require('./node_modules/gtfs/node_modules/mongoose');
Is there a nicer way to do that?

@brendannee
Copy link
Member

brendannee commented Nov 3, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants