Skip to content

neutrinoapp/neutrino-javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neutrino JavaScript SDK

API

Initialize

let app = Neutrino.app('{applicationId}');

Get collection

let collection = app.collection('cars');

Create object

let realtimeObject = collection.create({
  color: 'red',
  year: 2016
});

let simpleObject = collection.createSimple({
  color: 'blue',
  year: 2015
});

Get single object

let realtimeObject = collection.get('{object-id}');

or get simple object

let simpleObject = collection.getSimple('{object-id}');

Get array of objects

let allObjects = collection.get();

or with filter

let filteredObjects = collection.get({year: 2016});

Same goes for getSimple here too.

Object updates

Realtime objects are updated automatically with updates from the server and local ones.

let realtimeObject = collection.get('{object-id}');
realtimeObject.year = 2014;

Simple objects must be updated manually

let simpleObject = collection.getSimple('{object-id}');
simpleObject.year = 2014;
simpleObject.update();

Simple objects must also manually fetch updates from the server

let simpleObject = collection.getSimple('{object-id}');
console.log(simpleObject.year); //2015
//updated on the server to 2014
simpleObject.get();
console.log(simpleObject.year); //2014

Deleting objects

The delete method works the same for both realtime and simple objects.

let object = collection.get('{object-id}');
object.delete();

Deleting all items from collection

let realtimeArray = collection.get();
realtimeArray.forEach(object => object.delete());

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published