Skip to content

Instantly share code, notes, and snippets.

@mstade
Created November 26, 2014 17:54
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 mstade/85ac243abacce9a244ea to your computer and use it in GitHub Desktop.
Save mstade/85ac243abacce9a244ea to your computer and use it in GitHub Desktop.
emails index
// Documents look like:
{ profile:
{ emails:
[ { type: "account", "foo@bar.com" }
, { type: "work", "bar@foo.com" }
]
}
}
// 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("foo@bar.com", { index: "email" })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment