Document version support in Cosmos DB

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
0
down vote

favorite












Given these two document versions:




"id": "1",
"tags": [
"name": "a",
"name": "b"
],
"version": 1,



And:




"id": "2",
"tags": ["c","d"],
"version": 2,



My first attempt to normalize them to the latest shape on read was:



SELECT VALUE t.name
FROM c
JOIN t IN c.tags
WHERE c.version = 1

UNION ALL

SELECT VALUE t
FROM c
JOIN t IN c.tags
WHERE c.version = 2


It looks like that UNION is not supported. This one works though:



SELECT VALUE c.version = 1 ? t.name : t
FROM c
JOIN t IN c.tags


But it mixes multiple version translation in a single piece of code and will look ugly after introducing of more versions.



What is the best way to deal with versioning generally speaking then? I would prefer a single sectioned query to deal with all versions in a unified way instead of running stored procedure with multiple queries if possible.



P.S. I just think that UNION is a must feature here...







share|improve this question



























    up vote
    0
    down vote

    favorite












    Given these two document versions:




    "id": "1",
    "tags": [
    "name": "a",
    "name": "b"
    ],
    "version": 1,



    And:




    "id": "2",
    "tags": ["c","d"],
    "version": 2,



    My first attempt to normalize them to the latest shape on read was:



    SELECT VALUE t.name
    FROM c
    JOIN t IN c.tags
    WHERE c.version = 1

    UNION ALL

    SELECT VALUE t
    FROM c
    JOIN t IN c.tags
    WHERE c.version = 2


    It looks like that UNION is not supported. This one works though:



    SELECT VALUE c.version = 1 ? t.name : t
    FROM c
    JOIN t IN c.tags


    But it mixes multiple version translation in a single piece of code and will look ugly after introducing of more versions.



    What is the best way to deal with versioning generally speaking then? I would prefer a single sectioned query to deal with all versions in a unified way instead of running stored procedure with multiple queries if possible.



    P.S. I just think that UNION is a must feature here...







    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Given these two document versions:




      "id": "1",
      "tags": [
      "name": "a",
      "name": "b"
      ],
      "version": 1,



      And:




      "id": "2",
      "tags": ["c","d"],
      "version": 2,



      My first attempt to normalize them to the latest shape on read was:



      SELECT VALUE t.name
      FROM c
      JOIN t IN c.tags
      WHERE c.version = 1

      UNION ALL

      SELECT VALUE t
      FROM c
      JOIN t IN c.tags
      WHERE c.version = 2


      It looks like that UNION is not supported. This one works though:



      SELECT VALUE c.version = 1 ? t.name : t
      FROM c
      JOIN t IN c.tags


      But it mixes multiple version translation in a single piece of code and will look ugly after introducing of more versions.



      What is the best way to deal with versioning generally speaking then? I would prefer a single sectioned query to deal with all versions in a unified way instead of running stored procedure with multiple queries if possible.



      P.S. I just think that UNION is a must feature here...







      share|improve this question













      Given these two document versions:




      "id": "1",
      "tags": [
      "name": "a",
      "name": "b"
      ],
      "version": 1,



      And:




      "id": "2",
      "tags": ["c","d"],
      "version": 2,



      My first attempt to normalize them to the latest shape on read was:



      SELECT VALUE t.name
      FROM c
      JOIN t IN c.tags
      WHERE c.version = 1

      UNION ALL

      SELECT VALUE t
      FROM c
      JOIN t IN c.tags
      WHERE c.version = 2


      It looks like that UNION is not supported. This one works though:



      SELECT VALUE c.version = 1 ? t.name : t
      FROM c
      JOIN t IN c.tags


      But it mixes multiple version translation in a single piece of code and will look ugly after introducing of more versions.



      What is the best way to deal with versioning generally speaking then? I would prefer a single sectioned query to deal with all versions in a unified way instead of running stored procedure with multiple queries if possible.



      P.S. I just think that UNION is a must feature here...









      share|improve this question












      share|improve this question




      share|improve this question








      edited Apr 6 at 21:20









      200_success

      123k14142399




      123k14142399









      asked Apr 6 at 19:43









      Dmitry Nogin

      2,861523




      2,861523

























          active

          oldest

          votes











          Your Answer




          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "196"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f191437%2fdocument-version-support-in-cosmos-db%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes










           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f191437%2fdocument-version-support-in-cosmos-db%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Chat program with C++ and SFML

          Function to Return a JSON Like Objects Using VBA Collections and Arrays

          Will my employers contract hold up in court?