Request an array of nested objects

Let's say I have this JSON (a sample - a real life example can be found in the apple itunes rss channel ) stored in a RethinkDB table called 'test':

{ "feed": { "entry": [ { "title": { "label": "Some super duper app" }, "summary": { "label": "Bla bla bla..." } }, { "title": { "label": "Another awsome app" }, "summary": { "label": "Lorem ipsum blabla..." } } ] } } 

How do I write a ReQL query in JavaScript to get a summary of all entries ( entry ) that have a title containing the string "xyz"? I expect the query result to return an array of matching entry objects, not an array of matching feeds .

+8
rethinkdb
source share
1 answer

If I understood correctly what you want to do, this query should be what you are looking for:

 r.table("feeds").concatMap(function(doc) { return doc("feed")("entry") }).filter(function(entry) { return entry("title")("label").match("xyz") }) 
+11
source share

All Articles