Dojo OData Store

This page should serve as a general guide to the OData store API.

Summary

Returns an object's identity

Example

var id = store.getIdentity(someObject);
				

Summary

Retrieves an object by its identity. This will trigger a GET request to the server using the url this.target + "("+id+")".

Example

store.get("2").then(function(){
	// do something with item
});
				

Summary

Stores an object. This will trigger a POST or MERGE request to the server depending on if it is an incremental update

Example

store.put({
	'__metadata': {
		'type': 'Microsoft.SharePoint.DataService.DojoItem'
	},
	'Title': 'New Item'
}).then(function(success){
	// success
});
				

Summary

Adds an object. This will trigger a POST request to the server.

Example

store.add({
	'__metadata': {
		'type': 'Microsoft.SharePoint.DataService.DojoItem'
	},
	'Title': 'New Item'
}).then(function(success){
	// success
});
				

Summary

Deletes an object by its identity. This will trigger a DELETE request to the server.

Example

store.remove("27",{
	headers: {"X-RequestDigest": token}
}).then(function(success){
	// success
});
				

Summary

Queries the store for objects. This will trigger a GET request to the server, with the query added as a query string that adheres to OData URI conventions.

Example

store.query({
	Title: "Dojo*",
	$filter: "Foo eq 'Bar'"
}).then(function(items){
	// do something with items
});
				

Summary

Retrieves the children of an object.

Example

store.getChildren(someObject).then(function(children){
	// do something with items
});
				

Summary

Depending on the implementation of the OData endpoint being targeted, a form digest value may be required on specific requests. The store provides a convenient way to acquire this token.

Example

store.getFormDigest().then(function(token){
	store.put({
		'__metadata': {
			'type': 'Microsoft.SharePoint.DataService.DojoItem'
		},
		'Title': 'New Item'
	},{
		headers: {"X-RequestDigest": token}
	}).then(function(success){
		// success
	});
});