Instantly share code, notes, and snippets.

Embed
What would you like to do?
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