Difficulty: Beginner
Estimated Time: 60 minutes

Ensuring that data is available fast, consistent and available is key to successful applications. Yet offering this capabilities at scale can be difficult to implement.

By persisting data within the Fabric it provides the opportunity to reduce latency and increase availability by having the data geo-located at the edge.

In this scenario you will learn how to use Macrometa to persist data at edge locations that are then automatically replicated to other regions within the geofabric. This scenario will use the jsC8 library with Node.js to build a server-side JavaScript application for interacting with the C8 API for managing persistence.

The scenario explains:

  • Creating and Connecting to Fabric

  • Creating Collections

  • Inserting Data

  • Querying Data

  • Updating Data

  • Deleting Data

Persisting Data at the Edge with Javascript

Step 1 of 7

Setup

To start, install the jsC8 package using NPM.

npm install jsc8

The API uses async and await JavaScript functionality to provide clean, asynchronous code. Create a output async function that will be executed as part of the script.

var start = async function() {

//Connect

//Collection

//Index

//Create

//Query

//Update

//Delete

}

start();

The next steps will fill in the gaps and deliver the functionality to manage the data.

app.js