Home Update Writing server-side code in Azure Cosmos DB

Writing server-side code in Azure Cosmos DB

271


Azure Cosmos DB, Microsoft’s cloud-scale distributed database, is designed to supply the APIs and the storage mannequin you want on your functions. Want a NoSQL database? Use the MongoDB or Cassandra APIs. Need to work with graph queries? Use the Gremlin API. Azure’s personal desk storage APIs? They’re in there too. There’s even the choice of utilizing SQL.

But that’s solely the skin of Cosmos DB, its connection to the remainder of your utility. In many circumstances you’ll want so as to add extra code to handle your information and supply fundamental processing contained in the database. Traditional databases provide saved procedures and triggers to handle this, working server-side code near your information.

Going server-side in Cosmos DB

It’s no shock that Cosmos DB helps server-side code, with a built-in set of JavaScript APIs that run transactional code contained in the database, very similar to your SQL Server saved procedures. However, constructing and working these saved procedures is slightly completely different and requires some thought. You’re not working with one database on one server (or at most, a small native cluster). Now you’re working with distributed shops which may be continents aside and use new consistency fashions. These fashions are extra predictable than eventual consistency however don’t provide the locks which can be required by sturdy consistency fashions.

At the center of Cosmos DB’s saved procedures is its built-in JavaScript question API. Procedures get entry to plain database operations to create new objects and skim, replace, delete, and question present objects. They work inside Cosmos DB containers and are registered to particular collections in your database.



Source hyperlink

LEAVE A REPLY

Please enter your comment!
Please enter your name here