vidigami / backbone-orm

A polystore ORM for Node.js and the browser
http://vidigami.github.io/backbone-orm
MIT License
238 stars 15 forks source link

Quotes in query params uuids #55

Open rafaelrabeloit opened 8 years ago

rafaelrabeloit commented 8 years ago

I'm using Backbone in back and front end. I configured Backbone-ORM + Backbone-HTTP in my "client" web app and used Backbone-ORM + Backbone-Mongo + Backbone-REST in my REST API. It worked fine until I tested some queries using relationship keys from my client against the REST API.

Product.find({
  category_id: '5785228fc2ad8a23481dbb75'
}, function (err, products) {
  $("body").html(JSON.stringify(products));
});

The request that is made: http://localhost:8080/products?category_id=%225785228fc2ad8a23481dbb75%22

That means that the category_id here is interpreted as number represented in string, and therefore must be "quoted". But I don't think that is the expected result. Even more when the restify server, with the Backbone-REST on top of it, doesn't interpret it right and the GET returns [], even though the request without the quotes return it right.

kmalakoff commented 8 years ago

Sorry to hear. A couple of ideas:

1) Are you parsing the query parameters using middleware that calls JSONUtils.parseQuery(query)?

2) Are the schema relationships set up correctly on the server-side to define category_id as a Mongo ObjectId?