Created
September 20, 2013 03:22
-
-
Save mglukhovsky/6632926 to your computer and use it in GitHub Desktop.
Multiple filters with a lambda in RethinkDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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