0

I have a table videos with documents that look like this:

{
     "title":"Video Name",
     "description": "A description",
     "slug":"video-name",
     "studio": {
         "name": "Studio Name",
         "uid":"zyxwvut"
     },
     "uid":"abcdefghijkl"
}

I'm trying to grab related videos by the current video's studio by getting all videos with the studio.uid of zyxwvut, while also removing the ID of the requested video (uid of abcdefghijkl).

I've tried a few queries:

r.db('dev').table('videos').filter(function(video){ return video('studio')('uid').contains('zyxwvut').and(r.not(video('uid').eq("abcdefghijkl"))) })

with r.js:

r.db('dev').table('videos').filter(function(video){ return r.('(function (video) { return video.studio.uid == "zyxwvut"; })').and(r.not(video('uid').eq("abcdefghijkl"))) })

Am I going about this all wrong, or is it not possible?

synth3tk
  • 172
  • 1
  • 15
  • On top of neumino's answer, I also found out that I could create a secondary index based on the nest field, then just use that with a `getAll()` and filter out the current video ID. – synth3tk Oct 09 '14 at 17:40

1 Answers1

1

You were close. You can do:

r.db('dev').table('videos').filter(function(video) {
  return video("studio")("uid").eq("zyxwvut")
})
Jonathan
  • 8,771
  • 4
  • 41
  • 78
neumino
  • 4,342
  • 1
  • 18
  • 17