module.exports = {
    friendlyName: "Find",
  
    description: "Find Ecole.",
  
    inputs: {
        search: {
            type: "string",
          },
    },
  
    exits: {},
  
    fn: async function (inputs, exits) {
      const { id, user } = this.req.token;
      //console.log("ID", id, user.login, user.typeUser, user.codeEcole)
      // CONTROLE SUR USER ET RENVOI DES DATA EN FONCTION DE  USER CONNECTER
      // ACCESSIBLE UNIQUE PAR ADMIN ET ADMINISTRATION

      this.req.query.limit = this.req.query.limit || "10";
      this.req.query.skip = this.req.query.skip || "0";

      //let fixedAttr = [];
      let cond = {
        //codeEntite: codent,
        or: [
            { nom: { contains: inputs.search ? inputs.search.toUpperCase() : ""} },
            { pays: { contains: inputs.search ? inputs.search.toUpperCase() : "" } },
            { ville: { contains: inputs.search ? inputs.search.toUpperCase() : "" } },
    ],
      };
      let options = {
        ...this.req.query,
        fixCond: _.pick(cond, /*fixedAttr*/), 
        sort: "nom ASC",
      };
      let ecoles = await sails.helpers.paginator(Ecoles, cond, options);
      // All done.
      return exits.success(ecoles);
    },
  };
  