View Full Version : Store.Find

8 Mar 2010, 11:05 PM
I was checking the api and some of the threads, and I couldn't seem to have found my answer.

I was wondering if there was a way that store.find would look for a field that isn't equal to null or empty string?


store.find("name",!null); -- this code doesn't seem to be working for me

cause I just need to know if there's a null record?

Thanks :)

8 Mar 2010, 11:13 PM
In fact you are looking for records with some condition

so this code will return you all the records which has len of 'name' value equal to 3 as a MixedCollection:

var mixedCollection = store.queryBy ( function(record){ return record.get('name') && record.get('name').length === 3 });

I've found that in documentation, keep learning and practicing and you will be available to find that yourself without someones help

9 Mar 2010, 12:28 AM
Thanks for the reply.

Well I didn't used the query by cause I didn't need to get the record I just need to check if there's a record that has a name with a value. Which is why I opted to use Find that returns either 0 or -1.

Mike Robinson
9 Mar 2010, 7:11 AM
Remember that the store will only be searching through the list of records that it has, at this particular moment in time. It doesn't query the host to determine whether a record exists on the host.

So, unless you have all of the records in your possession (e.g. ArrayStore), you may need to issue an AJAX call to the host, asking it whether it has a qualifying record. The call will, of course, as always be asynchronous ...