Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'where' and regex issue #6

Open
livedata opened this issue Sep 4, 2012 · 2 comments
Open

'where' and regex issue #6

livedata opened this issue Sep 4, 2012 · 2 comments

Comments

@livedata
Copy link
Contributor

livedata commented Sep 4, 2012

Something is wrong with 'where' when passing regex there, for example:

  Page.paginate
    where:
        title: new RegExp("a")

It will not work - it does not work when i'm trying. BUT, when i'll hardcode the same condition inside of the helper function:

var foo = { title: new RegExp("a") };
Model.all({ limit: limit, offset: (page - 1) * limit, order: order, where: foo, function (err, records) {

It works! I was trying to debug it, with console.dir/log and everything was fine in console output, 'foo' looks exactly like 'opts.where':

{ title: /a/ }
{ title: /a/ }

I have no idea what is going on there, so i'm reporting it as issue ;-)

PS. as You can see i'm using coffeescript in my controllers, and mongoose db adapter, so perhaps it is (in some weird way) related?

@1602
Copy link
Owner

1602 commented Sep 4, 2012

Regular expressions in where conditions are deprecated.

On Tue, Sep 4, 2012 at 8:07 PM, livedata [email protected] wrote:

Something is wrong with 'where' when passing regex there, for example:

Page.paginate
where:
title: new RegExp("a")

It will not work - it does not work when i'm trying. BUT, when i'll
hardcode the same condition inside of the helper function:

var foo = { title: new RegExp("a") };Model.all({ limit: limit, offset: (page - 1) * limit, order: order, where: foo, function (err, records) {

It works! I was trying to debug it, with console.dir/log and everything
was fine in console output, 'foo' looks exactly like 'opts.where':

{ title: /a/ }
{ title: /a/ }

I have no idea what is going on there, so i'm reporting it as issue ;-)

PS. as You can see i'm using coffeescript in my controllers, and mongoose
db adapter, so perhaps it is (in some weird way) related?


Reply to this email directly or view it on GitHubhttps://github.com//issues/6.

Thanks,
Anatoliy Chakkaev

@livedata
Copy link
Contributor Author

livedata commented Sep 4, 2012

Hm, these are supported natively by mongodb aren't they? So (as far as i'm using multiple types of databases for my projects) is there any other way to fetch records using 'wildcards'? Something which would work with most of database engines?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant