const dbconn = require('../config/dbconn');

var methods = {
    getAllMailinglists: async function() {
        try {
            let rows:any = await dbconn.project.promise().query('CALL getAllLists')
            if (rows[0][0]) {
                return rows[0][0]
            } else { return null }
        } catch (err) {
            console.error(err)
        }
        return null
    },
    getProjectOverviewById: async function(projectId:number) {
        try {
            let rows:any = await dbconn.project.promise().query('CALL GetProjectInformationByProjectID(' + projectId+ ')')
            if (rows[0][0]) {
                return rows[0][0]
            } else { return null }
        } catch (err) {
            console.error(err)
        }
        return null
    },
    getProjectImagesById: async function(projectId:number) {
        try {
            let rows:any = await dbconn.project.promise().query('CALL getImagesByProjectID(' + projectId+ ')')
            if (rows[0][0]) {
                return rows[0][0]
            } else { return null }
        } catch (err) {
            console.error(err)
        }
        return null
    }
};

export = methods;