Created
November 26, 2014 17:54
-
-
Save mstade/85ac243abacce9a244ea to your computer and use it in GitHub Desktop.
emails index
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
// Documents look like: | |
{ profile: | |
{ emails: | |
[ { type: "account", "[email protected]" } | |
, { type: "work", "[email protected]" } | |
] | |
} | |
} | |
// Index should only look at the "account" type emails | |
r.table("users").indexCreate("email", function(user) { | |
return user("profile")("emails") | |
.filter(function(email) { | |
return email('type') === 'account' | |
}) | |
.map(function(email) { | |
return email('value') | |
}) | |
}, {multi: true}) | |
// No worky :o( | |
r.table("users").getAll("[email protected]", { index: "email" }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment