javascripttaffydb

search multiple terms in taffydb


If I make a TAFFYDB database like this:

customerDB.insert({
   "custID":"JONMI",
   "custName": "MIKE JONES",
   "custCity": "CHICAGO"
});

I can query by each individual term, like customer name:

var cName="MIKE";
customerDB({ "custName":{like:cName}}).each(function (record,recordnumber) { 

but is there a way to search by any term in a single query? By that I mean if I search by MIKE or CHICAGO or JONMI it would find a match.


Solution

  • from the TaffyDB documentation:

    customerDB([ {"custName":{likenocase:request.term}},
                   {"custCity":{likenocase:request.term}}, 
                   {"custID":{likenocase:request.term}} ] 
                 ).each(function (record,recordnumber) {    
    

    this is treaded like a logical "OR"