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

Testing support 'containsArray' keyword in where clause #22

Open
mako87 opened this issue Mar 23, 2016 · 1 comment
Open

Testing support 'containsArray' keyword in where clause #22

mako87 opened this issue Mar 23, 2016 · 1 comment
Assignees
Labels

Comments

@mako87
Copy link

mako87 commented Mar 23, 2016

I'm testing the implementation of the keyword 'containsArray' in where clause.
Find subarray value in array field

'containsArray': function _containsArray(r, row, field, value) {
    return row(field).default([]).setIntersection(r.expr(value).default([])).count().eq(value.length);
 }
where: {
    tags: {
         containsArray: ['tag1','tag2']
     }
}
@jmdobry
Copy link
Member

jmdobry commented Sep 20, 2016

The problem with containsArray is that it's ambiguous on whether it's ORing or ANDing together the values. You can already accomplish this with:

// OR them together
where: [
  { tags: { contains: 'tag1' } },
  'or',
  { tags: { contains: 'tag2' } },
  'or',
  { tags: { contains: 'tag3' } }
]
// AND them together
where: [
  { tags: { contains: 'tag1' } },
  { tags: { contains: 'tag2' } },
  { tags: { contains: 'tag3' } }
]

Note, this is with JSData 3.x and RethinkDBAdapter 3.x

@jmdobry jmdobry self-assigned this Sep 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants