3

I have a table that looks like this:

[                                                                                                                                                                                                              
    { "name": "Alpha", "values": {                                                                                                                                                                             
        "someProperty": 1                                                                                                                                                                                      
    }},                                                                                                                                                                                                        
    { "name": "Beta", "values": {                                                                                                                                                                              
        "someProperty": 2                                                                                                                                                                                      
    }},                                                                                                                                                                                                        
    { "name": "Gamma", "values": {                                                                                                                                                                             
        "someProperty": 3                                                                                                                                                                                      
    }}                                                                                                                                                                                                         
]

I want to select all records where someProperty is not in some array of values (e.g., all records where someProperty not in [1, 2]). I want to get back complete records, not just the values of someProperty.

How should I do this with RethinkDB?

spiffytech
  • 6,161
  • 7
  • 41
  • 57

1 Answers1

5

In python it would be:

table.filter(lambda doc: r.not(r.expr([1,2]).contains(doc["someProperty"]))

If the array comes from a subquery and you don't want to do it multiple times:

subquery.do(lambda array:
    table.filter(lambda doc: r.not(array.contains(doc["someProperty"]))))
Joe Doliner
  • 2,058
  • 2
  • 15
  • 19
  • What would be the most efficient way to do this if the array of values I want to filter out comes from a subquery? It looks like simply replacing r.expr(...) with the subquery would run the subquery for every document. – spiffytech Jan 25 '14 at 17:55