SitePen / dstore

A data infrastructure framework, providing the tools for modelling and interacting with data collections and objects.
http://dstorejs.io/
Other
281 stars 83 forks source link

_renderRangeParams broke #32

Closed neonstalwart closed 10 years ago

neonstalwart commented 10 years ago

something in this push (https://github.com/SitePen/dstore/compare/5d12808059...32540ce9bd) just broke _renderRangeParams (https://github.com/SitePen/dstore/blob/master/Request.js#L185)

cc @brandonpayton, @kriszyp

neonstalwart commented 10 years ago

sample code...

store
    .range(existingItems.length, existingItems.length + count)
    .forEach(function (item) {
        // ...
    })
kriszyp commented 10 years ago

The range method no longer exists, we are using fetchRange() now (which behaves like fetch()). What type of range parameters are you using (headers, named query parameters, or limit())?

neonstalwart commented 10 years ago

i'm using rql - so limit() is my range mechanism. i guess range should have been removed from Request if it no longer exists :wink:

will fetchRange hurt my use case since i want to do a forEach over a range?

kriszyp commented 10 years ago

Yes, fetchRange will hurt your use case, if you want to do a (safe) forEach, as fetchRange returns (a promise to) an array. We had talked about adding a forEach to the value result returned from fetch{Range} for convenience. As it is, you have to wait for the promise and iterate over the plain array.

neonstalwart commented 10 years ago

the ability to stream results would be very attractive if the API could support it. technology is advancing to where it is becoming possible so is there some way to not have the API be the limiting factor?

kriszyp commented 10 years ago

Yes, having forEach available on the result of fetchRange() does seem desirable. Also, https://github.com/SitePen/dstore/commit/1fcf181c5173af25bc34fdca539ead1dd9b0787c

neonstalwart commented 10 years ago

thanks - 1fcf181 is enough to close this issue out.