javascript - Using a variable name as a column name in TaffyDB -


i novice taffydb, faced following issue when trying querying db. db has column named type. tried record type equals "yes".

this line give me correct results:

var records = database({ "type": { "===": "yes" } }); 

but if tried pass these values parameters no records found.

eg.

var column= "type"; var operator = "==="; var value = "yes" ; var records = database({ column: { operator: value } }); 

simply need pass these values method parameters not in hard-coded way. should correct way done?

you'll need treat object array in order @ appropriate data

http://jsfiddle.net/darksbane/kjcty/

var products = taffy([{   "item":1,     "name":"blue ray player",     "price":99.99,     "type":"no" }, {     "item":2,     name:"3d tv",     price:1799.99,     "type":"yes" }]);  var column= "type"; var operator = "==="; var value = "yes" ; var object = {}; object[column]={}; object[column][operator]=value; console.log(object); var records = products(object).get(); console.log(records); $('#myul').append('<li>'+records[0].name+'</li>'); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -