ember.js - How can I do a "where in" type query using ember-data -


how can perform where-in type query using ember-data?

say have list of tags - how can use store query api relevant records have 1 of tags present?

something this:

 return this.store.find('tags', {             name: {                 "in": ['tag1', 'tag2', 'tag3']             }         }) 

there isn't built in support that. and, don't think needed.

the result after can obtained in 2 steps.

return this.store.find('posts'); // guess blog 

and in controller use computed property

filteredposts: function('model', function() {   var tags = ['tag1', 'tag2', 'tag3'];   return this.get('model').filter(function(post) {     if ( /* post has 1 of tags */ ) {     }     return false;   }); }); 

update: if there tens of thousands of tags?!

amother option send list of tags single argument end. you'll have bit of data processing before sending request , before querying.

return this.store.find('tags', {   tags: ['tag1', 'tag2', 'tag3'].join(', ') }) 

in api you'll know tags argument needs converted array before querying db.

so, better because avoid expensive nested loop caused use of filter. (expensive !== bad, has benefits)

it concern think there tens of thousands of tags, if going available in ember app they'll have big memory footprint , maybe more advanced needed in terms of app design.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -