Question

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?

Was it helpful?

Solution

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"]))))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top