read

Triggers a read operation on the DataSource that involves retrieving and processing the data. Returns a promise object from a jQuery Deferred for easy chaining of success and error callbacks.

var dataSource = new shield.DataSource({
    remote: {
        operations: ["skip", "take", "sort", "filter"],
        read: {
            url: "//services.odata.org/V3/Northwind/Northwind.svc/Products?$format=json&$inlinecount=allpages",
            dataType: "jsonp",
            jsonp: "$callback",
            data: function (params) {
                var odataParams = {};
                if (params.filter) {
                    odataParams["$filter"] = getODataFilter(params.filter);
                }
                if (params.sort && params.sort[0]) {
                    var sort = params.sort[0];
                    odataParams["$orderby"] = sort.path + (sort.desc ? " desc" : "");
                }
                if (params.skip) {
                    odataParams["$skip"] = params.skip;
                }
                if (params.take) {
                    odataParams["$top"] = params.take;
                }
                return odataParams;
            }
        }
    }
});

dataSource.read().then(function (data, fromCache) {
    console.log(data);
    console.log("is from cache: " + fromCache);
}, function (error) {
    console.error(error.message);
});