synth3tk
synth3tk

Reputation: 171

Get all documents with specific nested field value, sans one document

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?

Upvotes: 0

Views: 78

Answers (1)

neumino
neumino

Reputation: 4353

You were close. You can do:

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

Upvotes: 1

Related Questions