AQL- expected join possible in Arangodb and How?

血红的双手。 提交于 2020-01-21 10:17:06

问题


My Environment

  • ArangoDB Version: 3.5.2(the latest i think)
  • Storage Engine:RocksDB
  • Deployment Mode:Single Server
  • Deployment Strategy: Manual Start
  • Infrastructure:own
  • Operating System: Ubuntu 16.04
  • Total RAM in your machine: 8GB
  • Disks in use: 256GB

Problem: I have 2 collection and i have to perform join and want expected result is that possible in Arangodb ??

collection 1 :[
                { id :1 , name: "jack" },
                { id :2 , name: "ryan" },
                { id :3 , name: "sam" },
                { id :4 , name: "rick" },
                { id :5 , name: "jackie" },
                { id :6 , name: "roman" },
                { id :7 , name: "soul" },
                { id :8 , name: "brad" }
              ]  
collection 2 :[
                 { id :1 ,age:12 ,standard: 5 },
                 { id :5 ,age:14 ,standard: 7 },
                 { id :7,age:15 ,standard: 8 }
              ]

Expected result:

[
        { id :1 , name: "jack",standard: 5  },
        { id :2 , name: "ryan",standard: 5  },
        { id :3 , name: "sam" ,standard: 5 },
        { id :4 , name: "rick",standard: 5  },
        { id :5 , name: "jackie",standard: 7  },
        { id :6 , name: "roman",standard: 7  },
        { id :7 , name: "soul",standard: 8  },
        { id :8 , name: "brad",standard: 8  }
]

回答1:


You could try

FOR item in collection_1
    FOR item2 in collection_2
        FILTER item.id == item2.id
        RETURN MERGE(item, item2)

You can check the documentation: https://www.arangodb.com/docs/stable/aql/examples-join.html



来源:https://stackoverflow.com/questions/59265023/aql-expected-join-possible-in-arangodb-and-how

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!