thinky icon indicating copy to clipboard operation
thinky copied to clipboard

Implement bracket on queries

Open neumino opened this issue 10 years ago • 6 comments

It's not possible on Model, but it should be possible for Query.

neumino avatar Jun 04 '15 03:06 neumino

@neumino are you talking about the bracket ReQL term? Doesn't this already work on Query?

marshall007 avatar Jun 04 '15 04:06 marshall007

@marshall007 -- Model.filter({foo: 'bar})("field") doesn't work. An instance of Query is an object, not a function.

However, this works fine Model.filter({foo: 'bar}).getField("field"), Model.filter({foo: 'bar}).nth(0)

neumino avatar Jun 04 '15 04:06 neumino

Ah, I mentionned nth and getField, but bracket also works.

Model.filter({foo: 'bar}).bracket("field")

It's just that you can't do

Model.filter({foo: 'bar})("field")

neumino avatar Jun 04 '15 04:06 neumino

You're right. I was thinking of inner queries using r.row().

marshall007 avatar Jun 04 '15 05:06 marshall007

BTW, not sure where to doc this, but nth(0) throws a weird error when there's no results... I switched to .get(0) in promises so that I can just check if it's blank or not.

avimar avatar Sep 18 '15 11:09 avimar

This is expected, it's how RethinkDB behaves. You can catch the out of bound error in RethinkDB with default.

neumino avatar Sep 18 '15 14:09 neumino