src/plugins/query.js
function() {
            // ever notice we do this sort thing lots?
            var args = [].slice.call(arguments)
            ,   tmpl = args.shift()
            ,   last = args[args.length - 1]
            ,   qs   = tmpl.match(/\?/g)
            ,   q    = qs && qs.length > 0 ? interpolate(tmpl, args.slice(0, qs.length)) : tmpl
            ,   is   = new Function(this.record, 'return !!(' + q + ')')
            ,   r    = []
            ,   cb
            // iterate the entire collection
            // TODO should we allow for chained where() to filter __results? (I'm thinking no b/c creates funny behvaiors w/ callbacks)
            this.all(function(all){
                for (var i = 0, l = all.length; i < l; i++) {
                    if (is.call(all[i], all[i])) r.push(all[i])
                }
                // overwrite working results
                this.__results = r
                // callback / chain
                if (args.length === 1) this.fn(this.name, last).call(this, this.__results)   
            })
            return this 
        }
function() {
            // ever notice we do this sort thing lots?
            var args = [].slice.call(arguments)
            ,   tmpl = args.shift()
            ,   last = args[args.length - 1]
            ,   qs   = tmpl.match(/\?/g)
            ,   q    = qs && qs.length > 0 ? interpolate(tmpl, args.slice(0, qs.length)) : tmpl
            ,   is   = new Function(this.record, 'return !!(' + q + ')')
            ,   r    = []
            ,   cb
            // iterate the entire collection
            // TODO should we allow for chained where() to filter __results? (I'm thinking no b/c creates funny behvaiors w/ callbacks)
            this.all(function(all){
                for (var i = 0, l = all.length; i < l; i++) {
                    if (is.call(all[i], all[i])) r.push(all[i])
                }
                // overwrite working results
                this.__results = r
                // callback / chain
                if (args.length === 1) this.fn(this.name, last).call(this, this.__results)   
            })
            return this 
        }
function ( ) { // ever notice we do this sort thing lots? var args = [ ] . slice . call ( arguments ) , tmpl = args . shift ( ) , last = args [ args . length - 1 ] , qs = tmpl . match ( / \? / g ) , q = qs && qs . length > 0 ? interpolate ( tmpl , args . slice ( 0 , qs . length ) ) : tmpl , is = new Function ( this . record , 'return !!(' + q + ')' ) , r = [ ] , cb // iterate the entire collection // TODO should we allow for chained where() to filter __results? (I'm thinking no b/c creates funny behvaiors w/ callbacks) this . all ( function ( all ) { for ( var i = 0 , l = all . length ; i < l ; i ++ ) { if ( is . call ( all [ i ] , all [ i ] ) ) r . push ( all [ i ] ) } // overwrite working results this . __results = r // callback / chain if ( args . length === 1 ) this . fn ( this . name , last ) . call ( this , this . __results ) } ) return this }
query the storage obj
query the storage obj