简体   繁体   中英

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?

You were close. You can do:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM