balderdashy / balderdashy/sails
Cannot find all entries greater than "id" with sails-mongo
- Dominant language
- JavaScript
- Stars
- 22.8k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
**Sails version**: 1.1.0
**Node version**: 8.14.0
**NPM version**: 6.4.1
**DB adapter name**: sails-mongo
**DB adapter version**: 1.0.1
**Operating system**: Windows 10
For pagination, I am have my frontend send the "id" of the last entry. So I can fetch all entries "after" this id. I do this like this:
In Mongo I'm trying to fetch all entries with an id greater than 5c5da8cde14566339029260e. I'm doing this: `Blah.find({ id: { '>': '5c5da8cde14566339029260e' }})` but its not returning any results.
In my `config/models.js` I have made the update to `id: { type: 'string', columnName: '_id' },`. Here is my models.js file - https://gist.github.com/Noitidart/2fb4893551deccc638a28bc9cd4bbe8e
In Gitter, I asked for help and he thinks I am facing problems with ObjectId implicit conversions by waterline. Would be awesome if I could search by `>` id in mongo. This gurantees proper "cursor" paging.
Contributor guide
Research direction
Start with config/models.js and the model definition in the linked gist, then reproduce the Blah.find query against MongoDB using the listed Sails and sails-mongo versions. Trace how the string id and the `>` constraint are passed to the adapter; done means the query returns entries after the supplied id for the reported setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mongodb, node.js
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100