modules/query/LinksTable.js
function getLinks(db, callback) {

  // Check cache for links
  let cacheKey = db.id + "-" + 'links';
  let cache = cache_links.get(cacheKey);
  if ( cache !== null ) {
    return callback(null, cache);
  }

  // Build select statement
  let select = "SELECT link_category_title, link_title, link_description, link_url FROM rt_links;";

  // Query the database
  db.select(select, function(err, results) {

    // Database Query Error
    if ( err ) {
      return callback(err);
    }

    // List of links to return
    let rtn = [];

    // Parse each row
    for ( let i = 0; i < results.length; i++ ) {
      let row = results[i];

      // Build the link
      let link = new Link(
        row.link_category_title,
        row.link_title,
        row.link_description,
        row.link_url
      );

      // Add link to list
      rtn.push(link);
    }

    // Add links to cache
    cache_links.put(cacheKey, rtn);

    // Return the links with the callback
    return callback(null, rtn);

  });

}
function getLinks(db, callback) {

  // Check cache for links
  let cacheKey = db.id + "-" + 'links';
  let cache = cache_links.get(cacheKey);
  if ( cache !== null ) {
    return callback(null, cache);
  }

  // Build select statement
  let select = "SELECT link_category_title, link_title, link_description, link_url FROM rt_links;";

  // Query the database
  db.select(select, function(err, results) {

    // Database Query Error
    if ( err ) {
      return callback(err);
    }

    // List of links to return
    let rtn = [];

    // Parse each row
    for ( let i = 0; i < results.length; i++ ) {
      let row = results[i];

      // Build the link
      let link = new Link(
        row.link_category_title,
        row.link_title,
        row.link_description,
        row.link_url
      );

      // Add link to list
      rtn.push(link);
    }

    // Add links to cache
    cache_links.put(cacheKey, rtn);

    // Return the links with the callback
    return callback(null, rtn);

  });

}
function getLinks ( db , callback ) { // Check cache for links let cacheKey = db . id + "-" + 'links' ; let cache = cache_links . get ( cacheKey ) ; if ( cache !== null ) { return callback ( null , cache ) ; } // Build select statement let select = "SELECT link_category_title, link_title, link_description, link_url FROM rt_links;" ; // Query the database db . select ( select , function ( err , results ) { // Database Query Error if ( err ) { return callback ( err ) ; } // List of links to return let rtn = [ ] ; // Parse each row for ( let i = 0 ; i < results . length ; i ++ ) { let row = results [ i ] ; // Build the link let link = new Link ( row . link_category_title , row . link_title , row . link_description , row . link_url ) ; // Add link to list rtn . push ( link ) ; } // Add links to cache cache_links . put ( cacheKey , rtn ) ; // Return the links with the callback return callback ( null , rtn ) ; } ) ; }
Get all of the Agency link information from the database

@param {RightTrackDB} db The Right Track Database to query
@param {function} callback Callback function
@param {Error} callback.error Database Query Error
@param {Link[]} [callback.links] The selected Links
Get all of the Agency link information from the database