Comments (6)
Did you ever get this handled? I was having the same issue. On node 6.9.1. Setting limit without a constraint returns just fine of course.
In looking into it I think that this has been fixed or at least the code is currently much different in the master than what I was using in my project. I think at issue is that your tutorial (maybe @johnsonice was using this? https://www.youtube.com/watch?v=OhPFgqHz68o&t=3775s) If they followed that or just used https://github.com/travist/meanapp/tree/resourcejs/server to get started, it calls for v0.1.25, and this version still suffers from the bug that was fixed on 4/5/16 62ff2a5
I fixed it in that old version, in case anyone is unsure about the consequences of using the current version in their project by changing lines 323-324
.limit(parseInt(req.query.hasOwnProperty('limit') ? req.query.limit : pageRange.limit))
.skip(parseInt(req.query.hasOwnProperty('skip') ? req.query.skip : pageRange.skip))
Because for some reason it was not being considered an int.
Btw, @travist Thanks for the help in getting me started with my first REST API - I almost got excited that I had found and fixed a bug ;) for you.
from resourcejs.
@johnsonice can you provide example urls that you used, which didn't work?
from resourcejs.
@zackurben thanks for your quick response
here is an example
http://localhost:3000/resource?limit=99
i tried http://localhost:3000/resource?limit
it will just retrieve everything in the collection.
and this http://localhost:3000/resource?limit=-99
actually worked, returned 99 items. But i don't think it is how it should be.
no luck with ?skip at all.
I am very new to this. it could be I made a stupid mistake somewhere, but i just can't figure it out
from resourcejs.
@cycz1235 both skip and limit should work as follows:
example.com/resource?limit=5
example.com/resource?limit=5&skip=5
You can actually see them in the tests here: https://github.com/travist/resourcejs/blob/master/test/test.js#L688-L734
Just for background knowledge, what version of node are you running? I don't think this is an issue with ResourceJS, since the tests haven't complained, but maybe the version will tell us more.
Zack
from resourcejs.
@zackurben i am running on node v5.4.0
from resourcejs.
Is there a place in the docs where the use of limit, skip etc... are mentioned? I see tests for them, but nothing mentioning their use.
from resourcejs.
Related Issues (20)
- can't get example in README.md to work HOT 2
- Is there an admin / documentation html-interface for resourcejs? HOT 1
- Return code 200 and empty array instead of error 500 on GET request for empty collection HOT 1
- Type definitions HOT 1
- Allow passing of options down to `save()` method HOT 1
- Add ability to pass options to Document.save()
- Why does `Resource.respond()` call `next()` at the end HOT 2
- Add documentation for `hooks`
- Should `before` and `before[method]` handlers be merged?
- Allow Population on `get()` request
- Allow complex population
- Document all the fields that can be set on `req` in before handlers
- `get()` passes `search` to before hook
- Can't see the swagger UI
- Unable to use get for all data inside my react state HOT 1
- Bug / Question: Virtual Resources
- The regex doesn't work as well
- Fast JSON patch needs to be updated. HOT 2
- How to add custom Error Handler?
- Support mongoose 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from resourcejs.