This post demonstrates real examples of combining data from various Collections with FatFractal's datagraph.
This test application includes the following ffdl definition.
This test will show you how to retrieve specific object data using a Server Extension. We first get the Person with firstName "Bart" and then return only the firstName of the person object and the title of the debut episode they appeared in.
// The Client Code
ff.getObjFromExtension("/ff/ext/combineData?firstName=Bart", function(resp) {
//handle response
});
// The Server Exension Code
exports.combineData = function() {
var firstName = ff.getExtensionRequestData().httpParameters['firstName'];
var person = ff.getObjFromUri("/Persons/(firstName eq '" + firstName + "')")
var r = ff.response();
var debut = ff.getObjFromUri(person.ffUrl + "/BackReferences.Debuts");
var episode = ff.getReferredObject("episode", debut)
r.result = {firstName:person.firstName,debutEpisodeTitle:episode.title};
r.responseCode="200";
r.statusMessage = "returned custom object data";
r.mimeType = "application/json";
}
function Person() {
this.firstName = null;
this.lastName = null;
this.gender = null;
this.mother = null;
this.father = null;
this.siblings = null;
this.picture = null;
}
function Episode() {
this.title = null;
this.description = null;
this.season = null;
this.episode = null;
this.originalAir = null;
}
function Debut() {
this.person = new Person();
this.episode = new Episode();
}