Skip to content

Instantly share code, notes, and snippets.

@andijakl
Created October 11, 2018 07:57
Show Gist options
  • Save andijakl/b450e8b6bbe86c7ea65d7c398731eac2 to your computer and use it in GitHub Desktop.
Save andijakl/b450e8b6bbe86c7ea65d7c398731eac2 to your computer and use it in GitHub Desktop.
Add an item to the Cosmos DB from Node.js
const newItemId = Math.floor(Math.random() * 1000 + 10).toString();
let documentDefinition = {
"id": newItemId,
"name": "Angus MacGyver",
"state": "Building stuff"
};
// Add a new item to the container
console.log("** Create item **");
const createResponse = await container.items.create(documentDefinition);
console.log(createResponse.body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment