- If you want all rows with a value in the
b
property that has a value of b1
, you can just use the contains
method.
You use the contains
method (with the `filter method) in order to do that:
r.db('mine')
.tables('business')
.filter(function (row) { return row('b').contains('b1'); })
.run(conn)
In Ruby, that looks something like this:
r.db('test')
.table('hello')
.filter{ |row| row['b'].contains('b1') }
.run(conn)
In Python, that looks something like this:
r.db('test')
.table('hello')
.filter(lambda row: row['b'].contains('b1'))
.run(conn)
- If you want all rows with a value in the
b
property that has a value of b1
AND a value of b2
, you can just use the contains
method with the and
method.
JavaScript
r.db('mine')
.tables('business')
.filter(function (row) {
return row('b').contains('b1').and(row('b').contains('b2'));
})
.run(conn);
Python:
r.db('test')
.table('hello')
.filter(lambda row:
row['b'].contains('b1') & row['b'].contains('b2')
)
.run(conn)
- If you want all rows with a an array that only contains the values 'b1' or 'b2', then you can use Daniel's way and use the
.setDifference
method with the isEmpty
method.
JavaScript
r.db('mine')
.tables('business')
.filter(function (row) {
return row('b').contains('b1').and(row('b').contains('b2'));
})
.run(conn);
Python:
r.db('test')
.table('hello')
.filter(lambda row:
row['b'].contains('b1') & row['b'].contains('b2')
)
.run(conn)