demos/moviedb/demo-jquery.js
function generateDetails(id) {
  var m = db.getSchema().table('Movie');
  var ma = db.getSchema().table('MovieActor');
  var md = db.getSchema().table('MovieDirector');
  var a = db.getSchema().table('Actor');
  var d = db.getSchema().table('Director');

  var details = {};
  var promises = [];
  promises.push(
      db.select().
          from(m).
          where(m.id.eq(id)).
          exec().
          then(function(rows) {
            details['title'] = rows[0]['title'];
            details['year'] = rows[0]['year'];
            details['rating'] = rows[0]['rating'];
            details['company'] = rows[0]['company'];
          }));
  promises.push(
      db.select().
          from(ma).
          innerJoin(a, a.id.eq(ma.actorId)).
          where(ma.movieId.eq(id)).
          orderBy(a.lastName).
          exec().then(function(rows) {
            details['actors'] = rows.map(function(row) {
              return row['Actor']['lastName'] + ', ' +
                  row['Actor']['firstName'];
            }).join('<br/>');
          }));
  promises.push(
      db.select().
          from(md, d).
          where(lf.op.and(md.movieId.eq(id), d.id.eq(md.directorId))).
          orderBy(d.lastName).
          exec().then(function(rows) {
            details['directors'] = rows.map(function(row) {
              return row['Director']['lastName'] + ', ' +
                  row['Director']['firstName'];
            }).join('<br/>');
          }));
  Promise.all(promises).then(function() {
    displayDetails(details);
  });
}
function generateDetails(id) {
  var m = db.getSchema().table('Movie');
  var ma = db.getSchema().table('MovieActor');
  var md = db.getSchema().table('MovieDirector');
  var a = db.getSchema().table('Actor');
  var d = db.getSchema().table('Director');

  var details = {};
  var promises = [];
  promises.push(
      db.select().
          from(m).
          where(m.id.eq(id)).
          exec().
          then(function(rows) {
            details['title'] = rows[0]['title'];
            details['year'] = rows[0]['year'];
            details['rating'] = rows[0]['rating'];
            details['company'] = rows[0]['company'];
          }));
  promises.push(
      db.select().
          from(ma).
          innerJoin(a, a.id.eq(ma.actorId)).
          where(ma.movieId.eq(id)).
          orderBy(a.lastName).
          exec().then(function(rows) {
            details['actors'] = rows.map(function(row) {
              return row['Actor']['lastName'] + ', ' +
                  row['Actor']['firstName'];
            }).join('<br/>');
          }));
  promises.push(
      db.select().
          from(md, d).
          where(lf.op.and(md.movieId.eq(id), d.id.eq(md.directorId))).
          orderBy(d.lastName).
          exec().then(function(rows) {
            details['directors'] = rows.map(function(row) {
              return row['Director']['lastName'] + ', ' +
                  row['Director']['firstName'];
            }).join('<br/>');
          }));
  Promise.all(promises).then(function() {
    displayDetails(details);
  });
}
function generateDetails ( id ) { var m = db . getSchema ( ) . table ( 'Movie' ) ; var ma = db . getSchema ( ) . table ( 'MovieActor' ) ; var md = db . getSchema ( ) . table ( 'MovieDirector' ) ; var a = db . getSchema ( ) . table ( 'Actor' ) ; var d = db . getSchema ( ) . table ( 'Director' ) ; var details = { } ; var promises = [ ] ; promises . push ( db . select ( ) . from ( m ) . where ( m . id . eq ( id ) ) . exec ( ) . then ( function ( rows ) { details [ 'title' ] = rows [ 0 ] [ 'title' ] ; details [ 'year' ] = rows [ 0 ] [ 'year' ] ; details [ 'rating' ] = rows [ 0 ] [ 'rating' ] ; details [ 'company' ] = rows [ 0 ] [ 'company' ] ; } ) ) ; promises . push ( db . select ( ) . from ( ma ) . innerJoin ( a , a . id . eq ( ma . actorId ) ) . where ( ma . movieId . eq ( id ) ) . orderBy ( a . lastName ) . exec ( ) . then ( function ( rows ) { details [ 'actors' ] = rows . map ( function ( row ) { return row [ 'Actor' ] [ 'lastName' ] + ', ' + row [ 'Actor' ] [ 'firstName' ] ; } ) . join ( '<br/>' ) ; } ) ) ; promises . push ( db . select ( ) . from ( md , d ) . where ( lf . op . and ( md . movieId . eq ( id ) , d . id . eq ( md . directorId ) ) ) . orderBy ( d . lastName ) . exec ( ) . then ( function ( rows ) { details [ 'directors' ] = rows . map ( function ( row ) { return row [ 'Director' ] [ 'lastName' ] + ', ' + row [ 'Director' ] [ 'firstName' ] ; } ) . join ( '<br/>' ) ; } ) ) ; Promise . all ( promises ) . then ( function ( ) { displayDetails ( details ) ; } ) ; }
Display details results for selected movie.
@param {string} id
Display details results for selected movie .