typicaljoe / taffydb

TaffyDB - an open source JavaScript Database for your browser
http://taffydb.com
MIT License
2.21k stars 285 forks source link

Get() with filter no working #148

Closed Joslovefun closed 6 years ago

Joslovefun commented 7 years ago

Code: 112: console.log(my_index().stringify()); 113: console.log(my_index({id:1}).get()); Console LOG: JoeDocs.html:112 [{"id":[1],"OS":["Linux"],"Type":["Document"],"Head":["Setup OpenVMS cluster"],"Doc":["Set up linux cluster :0: Steps to perform "],"id":"T000003R000002","s":true},{"id":[2],"OS":["Unix"],"Type":["Document"],"Head":["Setup OpenVMS cluster"],"Doc":["Set up Unix cluster :0: Steps to perform "],"id":"T000003R000003","s":true},{"id":[3],"OS":["OpenVMS"],"Type":["Document"],"Head":["Setup OpenVMS cluster"],"Doc":["Set up OpenVMS cluster :0: Steps to perform "],"id":"T000003R000004","s":true}]

JoeDocs.html:113 []length: 0proto: Array(0)

Could you please let me know why "console.log(my_index({id:1}).get());" this is not returning anything?

Thanks!

typicaljoe commented 6 years ago

It appears your id column has the number one stored in an array. Be default the match isn't greedy enough to look into an array. I'd suggest switching to {id:1 in your record and see how that goes. An alternative that might work (but I haven't tested) would be to use 'has':

my_index({id:{has:1}}).get()