Open Iamlars opened 8 years ago
I had a similar issue:
product=[
{
"attributes":{"attribute_pa_excitation_emission":"350-448","pa_size":"200-assays"}
},
{
"attributes":{"attribute_pa_excitation_emission":"800-448","pa_size":"100-assays"}
}
];
db = TAFFY();
product.forEach(function(el) {
db.insert(el);
});
I can filter for "pa_size" but not for attribute_pa_excitation_emission
search = baza({'attributes':{"pa_size":"200-assays"}}).get(); //finds results
search = baza({'attributes':{"attribute_pa_excitation_emission":"800-448"}}).get(); // nothing
After 2 days i found out the rule: If the string contains "is" - no go. Any other string works good. Hope this helps someone.
!is also fails with number arrays. You can play with this sample and toggle the "is" operator to see the failure.
` var people= TAFFY();
people.insert({"fname":"Bruce","lname":"Wayne", "age": 18});
people.insert({"fname":"Peter","lname":"Parker", "age": 18});
people.insert({"fname":"Clark","lname":"Kent", "age": 23});
people.insert({"fname":"Tyrone","lname":"Lee", "age": 43});
people.insert({"fname":"Linda","lname":"Lee", "age": 39});
write("people({age: {'!is': [39, 18, 43]}}).get()");
write("people().count()");
write("people().first()");
write("people().select('fname')");
write("people.sort('fname desc');people().select('fname')");
function write(func){
var ret = eval(func);
var output = (typeof ret === 'object') ? JSON.stringify(ret) : ret;
document.getElementById('results').innerHTML+= '<li>' + func + '<br />=><b>'+output+'</b>';
}
I want to filter data use !is like '{city:{"!is": ["a","b","c"]}}',but it is not work well.