lib/library.js
function(languageSlug, projectSlug, resourceSlug) {
            let result =  query('select r.*, lri.translation_words_assignments_url from resource as r' +
                ' left join legacy_resource_info as lri on lri.resource_id=r.id' +
                ' where r.slug=? and r.project_id in (' +
                '  select id from project where slug=? and source_language_id in (' +
                '   select id from source_language where slug=?)' +
                ' )' +
                ' limit 1', [resourceSlug, projectSlug, languageSlug]);
            if(result.length > 0) {
                let res = result[0];
                // organize the status
                res.status = {
                    translate_mode: res.translate_mode,
                    checking_level: res.checking_level,
                    comments: res.comments,
                    pub_date: res.pub_date,
                    license: res.license,
                    version: res.version
                };
                delete res.translate_mode;
                delete res.checking_level;
                delete res.comments;
                delete res.pub_date;
                delete res.license;
                delete res.version;

                // store language and project slug for convenience
                res.source_language_slug = languageSlug;
                res.project_slug = projectSlug;

                // get formats
                res.formats = [];
                let formatResults =  query('select * from resource_format' +
                    ' where resource_id=?', [res.id]);
                res.imported = false;
                for(let format of formatResults) {
                    delete format.id;
                    delete format.resource_id;
                    format.imported = !!format.imported;
                    res.formats.push(format);
                    // TRICKY: this is not technically correct, but for convenience we attach the import status to the resource directly
                    if(format.imported) res.imported = true;
                }

                return res;
            }
            return null;
        }
function(languageSlug, projectSlug, resourceSlug) {
            let result =  query('select r.*, lri.translation_words_assignments_url from resource as r' +
                ' left join legacy_resource_info as lri on lri.resource_id=r.id' +
                ' where r.slug=? and r.project_id in (' +
                '  select id from project where slug=? and source_language_id in (' +
                '   select id from source_language where slug=?)' +
                ' )' +
                ' limit 1', [resourceSlug, projectSlug, languageSlug]);
            if(result.length > 0) {
                let res = result[0];
                // organize the status
                res.status = {
                    translate_mode: res.translate_mode,
                    checking_level: res.checking_level,
                    comments: res.comments,
                    pub_date: res.pub_date,
                    license: res.license,
                    version: res.version
                };
                delete res.translate_mode;
                delete res.checking_level;
                delete res.comments;
                delete res.pub_date;
                delete res.license;
                delete res.version;

                // store language and project slug for convenience
                res.source_language_slug = languageSlug;
                res.project_slug = projectSlug;

                // get formats
                res.formats = [];
                let formatResults =  query('select * from resource_format' +
                    ' where resource_id=?', [res.id]);
                res.imported = false;
                for(let format of formatResults) {
                    delete format.id;
                    delete format.resource_id;
                    format.imported = !!format.imported;
                    res.formats.push(format);
                    // TRICKY: this is not technically correct, but for convenience we attach the import status to the resource directly
                    if(format.imported) res.imported = true;
                }

                return res;
            }
            return null;
        }
function ( languageSlug , projectSlug , resourceSlug ) { let result = query ( 'select r.*, lri.translation_words_assignments_url from resource as r' + ' left join legacy_resource_info as lri on lri.resource_id=r.id' + ' where r.slug=? and r.project_id in (' + '  select id from project where slug=? and source_language_id in (' + '   select id from source_language where slug=?)' + ' )' + ' limit 1' , [ resourceSlug , projectSlug , languageSlug ] ) ; if ( result . length > 0 ) { let res = result [ 0 ] ; // organize the status res . status = { translate_mode : res . translate_mode , checking_level : res . checking_level , comments : res . comments , pub_date : res . pub_date , license : res . license , version : res . version } ; delete res . translate_mode ; delete res . checking_level ; delete res . comments ; delete res . pub_date ; delete res . license ; delete res . version ; // store language and project slug for convenience res . source_language_slug = languageSlug ; res . project_slug = projectSlug ; // get formats res . formats = [ ] ; let formatResults = query ( 'select * from resource_format' + ' where resource_id=?' , [ res . id ] ) ; res . imported = false ; for ( let format of formatResults ) { delete format . id ; delete format . resource_id ; format . imported = ! ! format . imported ; res . formats . push ( format ) ; // TRICKY: this is not technically correct, but for convenience we attach the import status to the resource directly if ( format . imported ) res . imported = true ; } return res ; } return null ; }
Returns a resource.

@param languageSlug {string}
@param projectSlug {string}
@param resourceSlug {string}
@returns {{}|null} the resource object or null if it does not exist
Returns a resource .