Azure Cosmos DB

Azure Cosmos DB

Azure Cosmos DB Presentation made during Node.js Paris meetup (https://www.meetup.com/fr-FR/Nodejs-Paris/events/256644371/)

9298dcce5b2b0e88d8ffbb837192ca98?s=128

Sylvain Pontoreau

December 05, 2018
Tweet

Transcript

  1. Node.js Paris 12/05/2018

  2. Premier Field Engineer @spontoreau In ❤️ with Co-organizer

  3. None
  4. https://azure.microsoft.com/en-us/services/cosmos-db/ https://azure.microsoft.com/en-us/blog/azure-cosmos-db-pushing-the-frontier-of-globally-distributed-databases/ @spontoreau Node.js Paris 12/05/2018

  5. @spontoreau Node.js Paris 12/05/2018

  6. https://azure.microsoft.com/en-us/blog/how-halo-5-guardians-implemented-social-gameplay-using-azure-documentdb/ @spontoreau Node.js Paris 12/05/2018

  7. @spontoreau Node.js Paris 12/05/2018

  8. @spontoreau Node.js Paris 12/05/2018

  9. A distributed system can only guarantee 2 constrains at the

    same time, not 3!
  10. @spontoreau Node.js Paris 12/05/2018

  11. @spontoreau Node.js Paris 12/05/2018

  12. @spontoreau Node.js Paris 12/05/2018 Azure Cosmos DB Account Databases Collections

    Documents
  13. None
  14. @spontoreau Node.js Paris 12/05/2018

  15. https://github.com/Azure/azure-cosmos-js https://docs.microsoft.com/en-us/javascript/api/@azure/cosmos @spontoreau Node.js Paris 12/05/2018 $ npm install @azure/cosmos

  16. const { database} = await client .databases .create({ id: databaseId

    }); const { container } = await database .container .create({ id: containerId }); @spontoreau Node.js Paris 12/05/2018 const client = new CosmosClient({ endpoint: myEndpoint, auth: { masterKey: myKey } });
  17. @spontoreau Node.js Paris 12/05/2018 const querySpec: SqlQuerySpec = { query:

    "SELECT root.firstName root.lastName FROM root WHERE root.email = @email", parameters: [{ name: "@email", value: "sypontor@microsoft.com" }] }; const { result } = await container .items .query(querySpec) .toArray(); const item = await container .item(id); const { body: readDoc } = item.read();
  18. @spontoreau Node.js Paris 12/05/2018 const person = { firstName: "Sylvain",

    lastName: "PONTOREAU", email: "sypontor@microsoft.com" }; const { body } = await container .items .create(person); if(body !== undefined) { console.log(body.id); } const item = await container .item(body.id); const { body: readDoc } = item.read(); readDoc.email = "sylvain @microsoft.com"; await item.replace(readDoc); await item.delete();
  19. @spontoreau Node.js Paris 12/05/2018 function hello(firstName, lastName) { return `Hello

    ${firstName} ${lastName}`; } SELECT udf.hello(root.firstName, root.lastName) as helloFullName FROM root
  20. @spontoreau Node.js Paris 12/05/2018 { "bindings": [ { "type": "cosmosDBTrigger",

    "name": "input", "direction": "in", "leaseCollectionName": "leases", "connectionStringSetting": "myConnectionString", "databaseName": "myDatabase", "collectionName": "myCollection", "createLeaseCollectionIfNotExists": true } ] } module.exports = function (context, input) { const id = input[0].id; context.log(`Document Id ${ id }`); context.done(); };
  21. @spontoreau Node.js Paris 12/05/2018

  22. None
  23. None
  24. None