Realtime Cloud Storage

ItemSnapshot

class ItemSnapshot

Class with the definition of an item snapshot.

Methods

ItemRef ref()

Creates and returns the corresponding ItemRef object.

Sample

// Create a storage reference
var storageRef = Realtime.Storage.create({
	applicationKey: "myApplicationKey",
	authenticationToken: "myAuthenticationToken"
});

// Create a table reference (TableRef)
var tableRef = storageRef.table("myTable");

// Create an item reference (ItemRef)
var itemRef = tableRef.item({ primary: "myId", secondary: 111222333444 });

// Example of a method that uses item snapshots
itemRef.get(function(itemSnapshot) {	
	
	// Creates a new reference to the item snapshot
	var newItemRef = itemSnapshot.ref();
}, 
function error(data) { 
	console.error("Error:", data); 
});

Object val()

Returns the attributes of the item.

Sample

// Create a storage reference
var storageRef = Realtime.Storage.create({
	applicationKey: "myApplicationKey",
	authenticationToken: "myAuthenticationToken"
});

// Create a table reference (TableRef)
var tableRef = storageRef.table("myTable");

// Create an item reference (ItemRef)
var itemRef = tableRef.item({ primary: "myId", secondary: 111222333444 });

// Example of a method that uses item snapshots
itemRef.get(function(itemSnapshot) {	
	
	// The item value
	var value = itemSnapshot.val();
}, 
function error(data) { 
	console.error("Error:", data); 
});