question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi,

I’m not the most familiar with Mongo nor Mongoose, but is it currently possible (or would it be possible to add) to fetch only unique (I think Mongoose has distinct for it?) results?

Currently querying

 gtfs.getStops({
    within: {
      lat: 59.435787,
      lon: 24.750738,
      radius: 0.3
    }
  }, {
    _id: 0,
    stop_name: 1,
    stop_id: 1
  })
  .then(stops => res.json(stops))

Results in a lot of duplicated results from my GTFS:

[{"stop_id":"1634","stop_name":"Viru"},{"stop_id":"1634","stop_name":"Viru"},
{"stop_id":"1634","stop_name":"Viru"},{"stop_id":"4341","stop_name":"Viru"},
{"stop_id":"4341","stop_name":"Viru"},{"stop_id":"4341","stop_name":"Viru"},
{"stop_id":"1291","stop_name":"Viru"},{"stop_id":"1291","stop_name":"Viru"},
{"stop_id":"1291","stop_name":"Viru"},{"stop_id":"1292","stop_name":"Viru"},
{"stop_id":"1292","stop_name":"Viru"},{"stop_id":"1292","stop_name":"Viru"},
{"stop_id":"1290","stop_name":"Viru"},{"stop_id":"1290","stop_name":"Viru"},
{"stop_id":"1290","stop_name":"Viru"},{"stop_id":"1635","stop_name":"Viru"},
{"stop_id":"1635","stop_name":"Viru"},{"stop_id":"1627","stop_name":"Estonia"},
{"stop_id":"1627","stop_name":"Estonia"},{"stop_id":"1627","stop_name":"Estonia"},
{"stop_id":"1630","stop_name":"Estonia"},{"stop_id":"1630","stop_name":"Estonia"},
{"stop_id":"1630","stop_name":"Estonia"},{"stop_id":"1628","stop_name":"Estonia"},
{"stop_id":"1628","stop_name":"Estonia"},{"stop_id":"1628","stop_name":"Estonia"},
...]

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
brendanneecommented, Mar 18, 2018

Thanks for your patience. I was able to find the issue.

  • The error messages on import were getting hidden, I pushed an updated version of node-gtfs that solves this (you don’t need to update though).

The issue was that your project has specified a different version of mongoose from the one one specificed by node-gtfs. In your package.json file it calls for mongoose 5.0.6, but node-gtfs specifics 5.0.9. This was causing two versions to get installed, and causing errors on import.

The way to fix this is to specify

"mongoose": "5.0.9",

in your package.json. Delete your node_modules folder and package-lock.json and run npm install again. You can check in node_modules/gtfs/node_modules to make sure a second version of mongoose isn’t getting installed.

0reactions
andreasvirkuscommented, Mar 19, 2018

Interesting, rimraffing node_modules and package-lock didn’t do the trick with 1.5.3, but worked fine with 1.6.0. Also all the stops are now unique (most likely since I don’t have to run skip-delete anymore, which might have caused the issue earlier : )

Thank you so much @brendannee for the constant support!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unique Definition & Meaning - Merriam-Webster
The meaning of UNIQUE is being the only one : sole. How to use unique in a sentence. Can something be very unique...
Read more >
72 Synonyms & Antonyms for UNIQUE - Thesaurus.com
unique · adj.alone, singular · adj.one-of-a-kind; without equal ...
Read more >
Unique Definition & Meaning - Dictionary.com
existing as the only one or as the sole example; single; solitary in type or characteristics: a unique copy of an ancient manuscript....
Read more >
Meaning of unique in English - Cambridge Dictionary
being the only existing one of its type or, more generally, unusual or special in some way: Each person's DNA is unique. uniquely....
Read more >
unique - Wiktionary
(not comparable) Being the only one of its kind; unequaled, unparalleled or unmatched. quotations ▽synonyms △ · Of a feature, such that only...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found