
module.exports = {


    friendlyName: 'Delete',


    description: 'Delete Information.',


    inputs: {
         id:{
           type:'number',
           required: true
         },
         anneeScolaire:{
            type:'string',
            required: true
          },
         

        /*codeEcole: {
            type: 'string',
            required: true
        },*/
    },


    exits: {
        notFound: {
            description: "Not found"
        }
    },


    fn: async function (inputs, exits) {

        const { id, user } = this.req.token;


        let information = await InformationsUser.find({ id: inputs.id, anneeScolaire: inputs.anneeScolaire, codeEcole: user.codeEcole }).then(_.first)
        if (!information) {

            return exits.notFound({ message: "Cette Information n\'existe pas, veuillez la modifier!" })
        }
        //console.log('ID ERROR', ecoles)

        await InformationsUser.destroy({ id: inputs.id, anneeScolaire: inputs.anneeScolaire, codeEcole: user.codeEcole }).fetch();

        // All done.
        return exits.success({ message: 'Done !' })

    }


};
