With ember-data is there a method for querying locally available objects?

StackOverflow https://stackoverflow.com/questions/9382863

  •  28-10-2019
  •  | 
  •  

문제

I have created a model that is populated locally on the client, upon initializing the application.

The findQuery method always does an ajax request, for example:

App.store.find(App.Person, {name: 'John'})

even in the case where an App.Person with name:John has already been loaded. The find method which takes an id, looks at the local storage first. But I need to be able to perform queries by attribute.

My question is whether there exists a method for performing queries strictly on locally available data.

도움이 되었습니까?

해결책

Use the DS.Store#filter method. A basic example is shown in the README on https://github.com/emberjs/data, section Filtering Loaded Records.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top