goodeggs / angular-cached-resource

An AngularJS module to interact with RESTful resources, even when browser is offline
MIT License
216 stars 29 forks source link

Objects as request parameters don't properly serialize in cache keys #44

Open hazeledmands opened 10 years ago

hazeledmands commented 10 years ago

When you make a request like this:

var Derp = $cachedResource('derp', 'http://herp.com/derp/:id')
Derp.query({where: {createdAt: { $lt: 5 } } })

rght now we're ending up with keys like this:

cachedResource://derp/array?query=[Object object]

when we should have something like this:

cachedResource://derp/array?query={where:{createdAt:{$lt:5}}}

We need to be careful that the serialization scheme is deterministic (alphabetize keys, etc) so that the same query always uses the same resource.