Collections find


#1

Hi,
I have problem with searching in collections.
I want to put variable in to whis:

SearchKey.findOne({keys: /.*variable.*/ })

I tried many ways but still dont know how to do this…
Please help


#2
var value = "JLGJALFW";
SearchKey.findOne({'keys': value})

works just fine for me :wink:


#3

but in your way it will find only JLGJALFW.
I want to something like this:
i have “abcd”, “abc”, “abcde”, "opl"
and when i type “ab” it will find all except “opl”.

I found how to do this: Collection.find({keys: {$regex: variable}})