Last active
December 31, 2015 04:59
-
-
Save neumino/7938008 to your computer and use it in GitHub Desktop.
blazedd - IRC - 2013.12.12
This file contains hidden or 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
r.table("users").filter( function(user) { | |
// map over all the keys of search | |
return r.expr(search).keys().map( function(key) { | |
// for each key, we return a boolean weather user(key) match search(key) (case insensitive) | |
return user(key).match( r.expr("(?i)").add(r.expr(search)(key)) ).ne(null) | |
}).reduce( function(left, right) { // Then for each boolean, we return left and right // so we perform a "and" operation here. | |
return left.and(right) | |
}) | |
}) | |
// To avoid manually the and, you can just look for false, and negate everything | |
var search={name: "michel"};r.table("users").filter( function(user) { | |
return r.expr(search).keys().map( function(key) { | |
return user(key).match( r.expr("(?i)").add(r.expr(search)(key)) ).ne(null) | |
}).contains(false).not() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment