Skip to content

Commit 0bbe79a

Browse files
code fix
1 parent 18c4795 commit 0bbe79a

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

articles/static-web-apps/database-azure-cosmos-db.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,10 @@ Add the following code between the `script` tags in *index.html*.
358358
```javascript
359359
async function get() {
360360
361-
const id = 1;
361+
const id = '1';
362362
363363
const gql = `
364-
query getById($id: Int!) {
364+
query getById($id: ID!) {
365365
person_by_pk(id: $id) {
366366
id
367367
Name
@@ -407,14 +407,15 @@ Add the following code between the `script` tags in *index.html*.
407407
```javascript
408408
async function update() {
409409
410-
const id = 1;
410+
const id = '1';
411411
const data = {
412+
id: id,
412413
Name: "Molly"
413414
};
414415
415416
const gql = `
416-
mutation update($id: Int!, $item: UpdatePersonInput!) {
417-
updatePerson(id: $id, item: $item) {
417+
mutation update($id: ID!, $_partitionKeyValue: String!, $item: UpdatePersonInput!) {
418+
updatePerson(id: $id, _partitionKeyValue: $_partitionKeyValue, item: $item) {
418419
id
419420
Name
420421
}
@@ -424,6 +425,7 @@ async function update() {
424425
query: gql,
425426
variables: {
426427
id: id,
428+
_partitionKeyValue: id,
427429
item: data
428430
}
429431
};
@@ -464,7 +466,7 @@ Add the following code between the `script` tags in *index.html*.
464466
async function create() {
465467
466468
const data = {
467-
id: "6",
469+
id: "3",
468470
Name: "Pedro"
469471
};
470472
@@ -518,19 +520,20 @@ Add the following code between the `script` tags in *index.html*.
518520
```javascript
519521
async function del() {
520522
521-
const id = 3;
523+
const id = '3';
522524
523525
const gql = `
524-
mutation del($id: Int!) {
525-
deletePerson(id: $id) {
526+
mutation del($id: ID!, $_partitionKeyValue: String!) {
527+
deletePerson(id: $id, _partitionKeyValue: $_partitionKeyValue) {
526528
id
527529
}
528530
}`;
529531
530532
const query = {
531533
query: gql,
532534
variables: {
533-
id: id
535+
id: id,
536+
_partitionKeyValue: id
534537
}
535538
};
536539
@@ -542,7 +545,7 @@ async function del() {
542545
});
543546
544547
const result = await response.json();
545-
console.log(`Record deleted: ${ result.data.deletePerson.Id }`);
548+
console.log(`Record deleted: ${ JSON.stringify(result.data) }`);
546549
}
547550
```
548551

0 commit comments

Comments
 (0)