Skip to content

Commit 9422f1f

Browse files
authored
Merge pull request #4 from burkeholland/master
Reformat output for a cleaner terminal
2 parents 07f3ad3 + fddc8b0 commit 9422f1f

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

app.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,39 @@ async function main() {
3535
.query(querySpec)
3636
.fetchAll();
3737

38-
console.log(items);
39-
40-
// Create a new item
38+
items.forEach(item => {
39+
console.log(`${item.id} - ${item.description}`);
40+
});
41+
42+
/** Create new item
43+
* newItem is defined at the top of this file
44+
*/
4145
const { resource: createdItem } = await container.items.create(newItem);
42-
console.log(`Created item: %s`, createdItem);
46+
47+
console.log(`\r\nCreated new item: ${createdItem.id} - ${createdItem.description}\r\n`);
4348

49+
/** Update item
50+
* Pull the id and partition key value from the newly created item.
51+
* Update the isComplete field to true.
52+
*/
4453
const { id, category } = createdItem;
4554

46-
// Update the item
4755
createdItem.isComplete = true;
56+
4857
const { resource: updatedItem } = await container
4958
.item(id, category)
5059
.replace(createdItem);
51-
console.log(`Updated item: %s`, updatedItem);
5260

53-
// Delete the item
61+
console.log(`Updated item: ${updatedItem.id} - ${updatedItem.description}`);
62+
console.log(`Updated isComplete to ${updatedItem.isComplete}\r\n`);
63+
64+
/**
65+
* Delete item
66+
* Pass the id and partition key value to delete the item
67+
*/
5468
const { resource: result } = await container.item(id, category).delete();
55-
console.log("Deleted item with id: %s", id);
69+
console.log(`Deleted item with id: ${id}`);
70+
5671
} catch (err) {
5772
console.log(err.message);
5873
}

0 commit comments

Comments
 (0)