Getting Started With DeltaDB

Live Demos

The Code

Load DeltaDB

<script src="https://cdn.jsdelivr.net/deltadb/0.0.10/deltadb.min.js"></script>

The User Interface

<h1>DeltaDB says <input id="greeting-in" type="text"
onkeypress="onKeyPress(event)" />
</h1>
<h3>DeltaDB says <em id="greeting-out"></em></h3>

Create the Database

var db = new DeltaDB('greetings-db',
'https://delta-dev.deltadb.io');

Create a Collection

var greetings = db.col('greetings');

Create the Document

var greeting = greetings.doc({ $id: 'greeting-id' });

Update the UI After the Doc is Loaded

greeting.on('load', function () {  document.getElementById('greeting-out').innerHTML =
greeting.get('text');
});

Update the UI When There are Remote Changes

greeting.on('attr:update', function (attr) {  document.getElementById('greeting-out').innerHTML = attr.value;});

Process Key Presses

function onKeyPress(e) {  if (e.keyCode === 13) { // pressed enter?    // save change
greeting.set({
text: document.getElementById('greeting-in').value });
// clear input box
document.getElementById('greeting-in').value = '';
}}

Congratulations!

Should DeltaDB be used in production?

What’s next?

--

--

A coder with a passion for JS, React, GraphQL, Docker and Serverless

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Geoff Cox

Geoff Cox

433 Followers

A coder with a passion for JS, React, GraphQL, Docker and Serverless