Skip to content

Instantly share code, notes, and snippets.

@mglukhovsky
Created September 20, 2013 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mglukhovsky/6632926 to your computer and use it in GitHub Desktop.
Save mglukhovsky/6632926 to your computer and use it in GitHub Desktop.
Multiple filters with a lambda in RethinkDB
Based on this question on SO: http://stackoverflow.com/questions/18907951/multiple-filters-with-a-lambda-in-rethinkdb
Test documents inserted into the table:
[
{
"id": "aad234" ,
"verified": true
} ,
{
"id": "234" ,
"verified": false
} ,
{
"id": "aad123" ,
"verified": true
} ,
{
"id": "123" ,
"verified": true
}
]
Filter with two expressions (using bpython):
>>> list(r.db('test').table('test').filter(r.row['verified'] == True and r.row['id'].match('^aad')).run())
[{u'verified': True, u'id': u'aad123'}, {u'verified': True, u'id': u'aad234'}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment