1

In my backend I have a list of available phone numbers: /api/phonenumbers. And I have a model for that: App.Phonenumber. I can get all my phone numbers with App.Phonenumber.find();

Now I would like to filter the list of phonenumbers, and get only those in a given country / city. The backend is able to perform this filtering by receiving a /api/phonenumbers?country=DE&city=Berlin query string.

  1. How can I extend my Phonenumber model to be able to pass these query string parameters?
  2. How can I perform a find using those query parameters?
4

1 回答 1

5

city如果并且country是模型上的属性,那么对于您的用例来说,这样做可能就足够了Phonenumber

App.Phonenumber.find({city: 'Berlin', country: 'DE'});

这应该会产生一个类似的 URL,例如:

?country=DE&city=Berlin

希望能帮助到你。

于 2013-08-11T11:58:51.510 回答