lib/qpm_media.js
function getTags(params, config, conn) {


  // defaults
  config = config || require('../config/config.js')

  params.limit = 100


  // main
  return new Promise((resolve, reject) => {

    if (!conn) {
      var conn = wc_db.getConnection(config.db)
    }

    if (params.uri) {
      var sql = 'SELECT t.tag from Media m left join MediaTag mt on m.id = mt.media_id left join Tag t on mt.tag_id = t.id  where m.uri = :uri order by t.tag LIMIT :limit '
    } else {
      var sql = 'SELECT * from Tag order by id LIMIT :limit '
    }
    debug(sql)

    conn.query(sql, { replacements: { "limit" : params.limit, "uri" : params.uri } }).then(function(ret){
      return resolve({"ret" : ret, "conn" : conn})
    }).catch(function(err) {
      return reject({"err" : err, "conn" : conn})
    })

  })

}
function getTags(params, config, conn) {


  // defaults
  config = config || require('../config/config.js')

  params.limit = 100


  // main
  return new Promise((resolve, reject) => {

    if (!conn) {
      var conn = wc_db.getConnection(config.db)
    }

    if (params.uri) {
      var sql = 'SELECT t.tag from Media m left join MediaTag mt on m.id = mt.media_id left join Tag t on mt.tag_id = t.id  where m.uri = :uri order by t.tag LIMIT :limit '
    } else {
      var sql = 'SELECT * from Tag order by id LIMIT :limit '
    }
    debug(sql)

    conn.query(sql, { replacements: { "limit" : params.limit, "uri" : params.uri } }).then(function(ret){
      return resolve({"ret" : ret, "conn" : conn})
    }).catch(function(err) {
      return reject({"err" : err, "conn" : conn})
    })

  })

}
function getTags ( params , config , conn ) { // defaults config = config || require ( '../config/config.js' ) params . limit = 100 // main return new Promise ( ( resolve , reject ) => { if ( ! conn ) { var conn = wc_db . getConnection ( config . db ) } if ( params . uri ) { var sql = 'SELECT t.tag from Media m left join MediaTag mt on m.id = mt.media_id left join Tag t on mt.tag_id = t.id  where m.uri = :uri order by t.tag LIMIT :limit ' } else { var sql = 'SELECT * from Tag order by id LIMIT :limit ' } debug ( sql ) conn . query ( sql , { replacements : { "limit" : params . limit , "uri" : params . uri } } ) . then ( function ( ret ) { return resolve ( { "ret" : ret , "conn" : conn } ) } ) . catch ( function ( err ) { return reject ( { "err" : err , "conn" : conn } ) } ) } ) }
Get list of tags
@param {Object} params  Info about tags.
@param {Object} config  The optional config.
@param {Object} conn    The optional db connection.
@return {Object} Promise with success or fail.
Get list of tags