跨文档集合的内部/外部连接 [英] INNER/OUTER join accross document collections

查看:93
本文介绍了跨文档集合的内部/外部连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am searching for a solution with Javascript stored procedures and UDF's for CosmosDB, where you can perform an INNER/OUTER JOIN between two or more document collections.

我一直没有成功.

据我了解,Javascript存储过程在一个集合中运行,并且无法访问/引用另一个集合中的数据.

From my understanding, Javascript Stored Procedures run within a collection, and cannot access/reference data in another collection.

请考虑以下内容:

客户

Customer

{
    "id": "d02e6668-ce24-455d-b241-32835bb2dcb5",
    "Name": "Test User One",
    "Surname": "Test"
}

=" strong-family:inherit; font-size:15px; background -color:#ffffff; margin:0px; padding:0px; border:0px; font-style:inherit; font-variant:inherit; line-height:inherit; vertical-align:baseline>

Agreement

{
    "id": "ee1094bd-16f4-45ec-9f5e-7ecd91d4e729",
    "CustomerId": "d02e6668-ce24-455d-b241-32835bb2dcb5"
    "RetailProductVersionInstance": 
    [
                {
        "id": "8ce31e7c-7b1a-4221-89a3-449ae4fd6622",
        "RetailProductVersionId": "ce7a44a4-7e49-434b-8a51-840599fbbfbb",
        "AgreementInstanceUser": {
            "FirstName": "Test",
            "LastName": "Test",
            "AgreementUserTypeId": ""
        },
        "AgreementInstanceMSISDN": {
            "IsoCountryDialingCode": null,
            "PhoneNumber": "0832222222",
            "NetworkOperatorId": "30303728-9983-47f9-a494-1de853d66254"
        },
        "RetailProductVersionInstanceState": "IN USE",
        "IsPrimaryRetailProduct": true,
        "RetailProductVersionInstancePhysicalItems": [
            {
                "id": "f8090aba-f06b-4233-9f9e-eb2567a20afe",
                "PhysicalItemId": "75f64ab3-81d2-f600-6acb-d37da216846f",
                "RetailProductVersionInstancePhysicalItemNumbers": [
                    {
                        "id": "9905058b-8369-4a64-b9a5-e17e28750fba",
                        "PhysicalItemNumberTypeId": "39226b5a-429b-4634-bbce-2213974e5bab",
                        "PhysicalItemNumberValue": "KJDS959405"
                    },
                    {
                        "id": "1fe09dd2-fb8a-49b3-99e6-8c51df10adb1",
                        "PhysicalItemNumberTypeId": "960a1750-64be-4333-9a7f-c8da419d670a",
                        "PhysicalItemNumberValue": "DJDJ94943"
                    }
                ],
                "RetailProductVersionInstancePhysicalItemState": "IN USE",
                "DateCreatedUtc": "2018-11-21T13:55:00Z",
                "DateUpdatedUtc": "2020-11-21T13:55:00Z"
            }
        ]
    }
    ]
}



零售产品

RetailProduct

{
    "id": "ce7a44a4-7e49-434b-8a51-840599fbbfbb",
    "FriendlyName": "Data-Package 100GB",
    "WholeSaleProductId": "d054dae5-173d-478b-bb0e-7516e6a24476"
}


WholeSaleProduct:

WholeSaleProduct:

{
    "id": "d054dae5-173d-478b-bb0e-7516e6a24476",
    "ProductName": "Data 100",
    "ProviderLiabilities": []
}


Relationships:

  • Agreement.RetailProductVersionInstance.RetailProductVersionId链接到RetailProduct.id
  • Agreement.CustomerId links to Customer.id
  • Agreement.RetailProductVersionInstance.RetailProductVersionId links to RetailProduct.id
  • RetailProduct.WholeSaleProductId links to WholeSaleProduct.id

我该如何在CosmosDB中编写Javascript存储过程来执行这4个集合之间的联接?

How, would I write a Javascript Stored Procedure, in CosmosDB, to perform joins between these 4 collections?

推荐答案

Newbie_Guy

Hi Newbie_Guy,

请对以下功能请求进行评论和投票:

Please comment and up-vote the following feature request: Support multiple collections in stored procedures

作为一种可能的解决方案,您可以在从CosmosDB中检索到它后,从缓存或在客户端上组装它.让我看看我能找到什么.

As a possible solution, you can assemble this from cache or on the client after being retrieved from CosmosDB. Let me see what I can find.

迈克


这篇关于跨文档集合的内部/外部连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆