According to the Ember Data docs regarding queries:
You can query the server by passing a hash to find().
The contents of the hash is opaque to Ember Data; it is up to your
server to interpret it and return a list of records.
If you want client-side filtering you can use the filter()
method of Ember.Array
. This example displays a computed property that contains a subset of the original array contents. This computed array only shows items that match what is typed into the box.
JSBin Example
Javascript:
App = Ember.Application.create({});
App.IndexRoute = Ember.Route.extend({
setupController: function(controller) {
controller.set('content', [
Ember.Object.create({name: 'Joe'}),
Ember.Object.create({name: 'Frank'}),
Ember.Object.create({name: 'John'}),
Ember.Object.create({name: 'Billy'}),
Ember.Object.create({name: 'John'}),
Ember.Object.create({name: 'Johnny'})
]);
}
});
App.IndexController = Ember.ArrayController.extend({
content: [],
filter: "",
filteredContent: function() {
var filter = this.get('filter');
return this.get('content').filter(function(item, index, enumerable){
return item.get('name').toLowerCase().match(filter.toLowerCase());
});
}.property('filter', 'content.@each')
});
Handlebars:
<script type="text/x-handlebars" data-template-name="index">
<h2>Index Content:</h2>
<span>Filter: </span>{{view Ember.TextField valueBinding=filter}}
<ul>
{{#each item in filteredContent}}
<li>{{item.name}}</li>
{{/each}}
</ul>
</script>