js-data-rethinkdb icon indicating copy to clipboard operation
js-data-rethinkdb copied to clipboard

It does not support 'contains' keyword in findAll() query

Open gutenye opened this issue 9 years ago • 8 comments

I tried

User.findAll({where: {tags: {"contains": "a"}}}).then(..)

But got

error ReqlDriverError {message: "Annonymous function returned `undefined`. Did you forget a `return`?"}

It works in filter() though. So it seems that the adapter does not support "contains" keyword?

gutenye avatar Aug 28 '15 01:08 gutenye

I guess the contains operator was added to jsdata, but not to the adapter. On Aug 27, 2015 6:00 PM, "Guten Ye" [email protected] wrote:

I tried

User.findAll({tags: {"contains": "a"}}).then(..)

But got

error ReqlDriverError {message: "Annonymous function returned undefined. Did you forget a return?"}

It works in filter() though. So it seems the adapter does not support "contains" keyword?

— Reply to this email directly or view it on GitHub https://github.com/js-data/js-data-rethinkdb/issues/10.

jmdobry avatar Aug 28 '15 03:08 jmdobry

Is this the adapter? Does contains need to be added here, or elsewhere?

recipher avatar Sep 04 '15 10:09 recipher

Needs to be added to the adapter.

jmdobry avatar Sep 04 '15 15:09 jmdobry

Support for contains, |contains, notContains and |notContains has been added to 3.x alpha.

jmdobry avatar Mar 18 '16 05:03 jmdobry

Is there a test or example for how contains works or is there something I'm doing wrong here? I'm on [email protected], and trying to do something simple like ...

Survey.findAll({ where: { name: { contains: 'survey 2' } } })

... is giving a ReQL error:

ReqlLogicError: Cannot convert STRING to SEQUENCE in:
r.db("test").table("survey").filter(function(var_5) {
    return var_5("name").default([]).contains("survey 2")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
})

mikew avatar Oct 06 '16 18:10 mikew

I believe contains is an Array operation, and doesn't work on strings. It only works on sequences: https://rethinkdb.com/api/javascript/#contains

jmdobry avatar Oct 13 '16 23:10 jmdobry

That was totally it. I've since migrated to version 3 and adapted like/notLike from https://github.com/js-data/js-data-rethinkdb/pull/12 into it, can send a PR if you'd like

mikew avatar Oct 14 '16 01:10 mikew

Yeah, I'd be interested at looking at your PR.

jmdobry avatar Oct 17 '16 04:10 jmdobry