JavaScript DataSource Schema Definition

Shield UI DataSource provides a series of schema settings that describe how the data is parsed and mapped into suitable JavaScript objects. The schema is a JavaScript object that is specified either through the schema setting during initilization, or using the schema property after the DataSource has been initialized:

var ds = new shield.DataSource( {
	schema: {
		//specifies the path to the data array in the result object after read()
		//can be a function accepting the result object and returning an array
		data: "result.data",
		
		//specifies the path to the total item count in the result object after read()
		//can be a function accepting the result object and returning a number
		count: "result.count",
		
		//specifies field types and maps fields to other field names
		fields: {
			productId: {
				//map data from the "id" field to a new "productId" field
				path: "id", 
				//convert data values to numbers
				type: "number"
			},
			productName: {
				path: "name"
			},
			launched: {
				path: "launchDate",
				type: "date"
			},
			discontinued: {
				type: "bool"
			}
		}
	}
});
ds.read().then(function () {
	var dataView = ds.view;
	//dataView is an array of objects, where each object has a field "productId"
	//containing numeric values, "productName" containing strings, "launched"
	//containing Date objects and "discontinued" containing Boolean values
});