Skip to content

Instantly share code, notes, and snippets.

@neumino
Created September 13, 2013 18:11
Show Gist options
  • Save neumino/6554108 to your computer and use it in GitHub Desktop.
Save neumino/6554108 to your computer and use it in GitHub Desktop.
Filtering nested arrays with RethinkDB
r.table("test").filter( function(doc) {
return doc("adresses").contains(function(adress) {
return adress("city").eq("Paris")
})
})
/*
{
name: "Bob",
adresses: [
{
country: "France",
city: "Paris"
}
]
}
*/
@kedlas
Copy link

kedlas commented Sep 18, 2019

Looks like as required in RethinkDB 2.3.6. It returns the whole objects which contains addresses that contain at least one city=Havana. Of course it returns other addresses too, because only filter for searching was used (no data plucking).

Btw thanks for the query, i was searching for exactly this.

@HeikoMueller
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment