module.exports = {


    friendlyName: 'Modify',


    description: 'Modify user.',


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

        titre: {
            type: 'string',
            required: true
        },
        description: {
            type: 'string',
        },

        codeClasse: {
            type: 'string',
        },
        qui: {
            type: 'string',
        },

    },


    exits: {
        notFound: {
            statusCode: 404
        },

    },


    fn: async function (inputs, exits) {

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


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

            return exits.notFound({ message: "Cette Information n\'existe pas, veuillez la modifier!" })
        }

        let informationUpdate = await InformationsUser.update({ id: inputs.id, codeEcole: user.codeEcole }, inputs).fetch()

        // All done.
        return exits.success({
            informationUpdate
        });

    }

};
