Sails (Part 2)

Neil HaddleyOctober 12, 2021

Sails and the Azure Cosmos DB API for MongoDB

DevOpsAzuresails-jscosmos-dbmongodbazure

Articles api

BASH
1% sails generate api articles
I generated the articles API

I generated the articles API

Blueprint API

Once the articles API was created, I used the Blueprint API to create article items. I navigated to http://localhost:1337/articles.

/articles

/articles

/articles/Create?title=<title>&body=<body>

/articles/Create?title=<title>&body=<body>

Push to GitHub

The new code was published to https://haddley-sails.azurewebsites.net after I pushed it to the GitHub repository.

I pushed to GitHub

I pushed to GitHub

GitHub action in progress

GitHub action in progress

GitHub action completed

GitHub action completed

Creating and Destroying items

Once the articles model update was published to Azure, I used the Blueprint API to create and remove (destroy) article items. I navigated to https://haddley-sails.azurewebsites.net/articles.

/articles/Create?...

/articles/Create?...

/articles/Destroy?...

/articles/Destroy?...

/articles

/articles

Azure Cosmos DB API for MongoDB

In the screenshots above I had been using local disk storage with the sails-disk adapter. I updated the application to use the Azure Cosmos DB for MongoDB.

Overview

Overview

I updated connections.js

I updated connections.js

I updated the model

I updated the model

/articles

/articles

Data Explorer

Data Explorer

I pushed the changes to GitHub

I pushed the changes to GitHub

GitHub action in progress

GitHub action in progress

https://haddley-sails.azurewebsites.net/articles connected to Azure Cosmos DB for MongoDB

https://haddley-sails.azurewebsites.net/articles connected to Azure Cosmos DB for MongoDB