Ditto JS SDK
Ditto is a cross platform SDK that allows mobile, web, and IoT apps to sync
with and even without connectivity.
IMPORTANT: The Ditto JS SDK is currently in an early alpha stage. As such,
it is neither complete nor stable. Expect the API to change at any time.
Getting Started
Add the Ditto NPM package to your project:
npm install --save @dittolive/ditto
You can then import it in your source and start using it:
import { Ditto } from '@dittolive/ditto'
(async () => {
// Create a Ditto context:
const identity = { environment: 'development', appName: 'live.ditto.playground', siteID: BigInt('123') }
const ditto = await new Ditto(identity, 'playground')
// Get hold of a collection:
const cars = ditto.store.collection('cars')
// Insert an entry:
const fordBlack = {model: "Ford", color: "black"}
await cars.insert({id: "ford-black-123", value: fordBlack})
// Find an entry by ID:
const foundFordBlack = await cars.findByID('ford-black-123')
console.log(foundFordBlack)
// Remove an entry:
await cars.findByID('ford-black-123').remove()
// Done:
console.log("Done, over and out.")
})()
Copyright
Ditto JS SDK is a commercial product. Please consult LICENSE.md
within this
package for license details.
Copyright © 2019 - 2021 DittoLive, Inc. All rights reserved.