Document version support in Cosmos DB
Clash 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...
sql azure azure-cosmosdb
add a comment |Â
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...
sql azure azure-cosmosdb
add a comment |Â
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...
sql azure azure-cosmosdb
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...
sql azure azure-cosmosdb
edited Apr 6 at 21:20
200_success
123k14142399
123k14142399
asked Apr 6 at 19:43
Dmitry Nogin
2,861523
2,861523
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password