js-data-rethinkdb
js-data-rethinkdb copied to clipboard
It does not support 'contains' keyword in findAll() query
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?
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 areturn
?"}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.
Is this the adapter? Does contains need to be added here, or elsewhere?
Needs to be added to the adapter.
Support for contains
, |contains
, notContains
and |notContains
has been added to 3.x alpha.
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")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
})
I believe contains
is an Array operation, and doesn't work on strings. It only works on sequences: https://rethinkdb.com/api/javascript/#contains
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
Yeah, I'd be interested at looking at your PR.