deyles-zz / sculejs

SculeJS - data structures for the web
165 stars 24 forks source link

Does scule has queries with like ? #16

Closed DOKI4ever closed 11 years ago

DOKI4ever commented 11 years ago

Hi Dan,

First of all i would like to thank you for your solution. It's great!!

but i have a doubt... Can you perform queries with like, as in mysql?

The problem that i have is that i have a search function, which should search in the collection of items, right now i'm doing it with sql..

'SELECT * FROM places WHERE place LIKE "%'+placename+' %"'

And i would like to use scule but i'm not sure of how can i perform this query.... (placename can be from the full name of the place, to just some letters, park would return parks and parkings, street would return all the places with a street in their name...)

Thank you!

Luis

deyles-zz commented 11 years ago

Hey Luis,

Sure, that should be possible - try something like the following:

var collection = scule.factoryCollection('scule+dummy://test', {secret:'mysecretkey'});
var o = collection.find({place:new RegExp('/' + placename + '/', 'gi')});
davidcyp commented 7 years ago

Actually, it should be without the '/', eg.:

var collection = scule.factoryCollection('scule+dummy://test', {secret:'mysecretkey'});
var o = collection.find({place:new RegExp(placename, 'gi')});